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"))
;; Put whatever you want to be called before server running here
(get "/"
(lambda ()
(define* (get-content #:key non-blocking?)
(let* ((uri
(string->uri
(string-append
@ -34,12 +33,20 @@
(socket
(open-socket-for-uri uri)))
;; If you comment out the following line, this example will work
(fcntl socket F_SETFL (logior O_NONBLOCK (fcntl socket F_GETFL)))
(when non-blocking?
(fcntl socket F_SETFL (logior O_NONBLOCK (fcntl socket F_GETFL))))
(let ((response
body
(http-get uri
#:port socket
#: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))))