This commit is contained in:
Christopher Baines 2025-07-16 14:26:50 +01:00
parent 9c99aa375b
commit 51277fa41d

17
ENTRY
View file

@ -20,8 +20,7 @@
(add-to-load-path (string-append (current-toplevel) "/lib")) (add-to-load-path (string-append (current-toplevel) "/lib"))
;; Put whatever you want to be called before server running here ;; Put whatever you want to be called before server running here
(get "/" (define* (get-content #:key non-blocking?)
(lambda ()
(let* ((uri (let* ((uri
(string->uri (string->uri
(string-append (string-append
@ -34,12 +33,20 @@
(socket (socket
(open-socket-for-uri uri))) (open-socket-for-uri uri)))
;; If you comment out the following line, this example will work (when non-blocking?
(fcntl socket F_SETFL (logior O_NONBLOCK (fcntl socket F_GETFL))) (fcntl socket F_SETFL (logior O_NONBLOCK (fcntl socket F_GETFL))))
(let ((response (let ((response
body body
(http-get uri (http-get uri
#:port socket #:port socket
#:streaming? #t))) #:streaming? #t)))
(simple-format #f "~A" (json->scm body)))))) (json->scm body))))
(get "/"
(lambda ()
(simple-format #f "~A" (get-content #:non-blocking? #t))))
(get "/working"
(lambda ()
(simple-format #f "~A" (get-content #:non-blocking? #f))))