Update
This commit is contained in:
parent
9c99aa375b
commit
51277fa41d
1 changed files with 12 additions and 5 deletions
17
ENTRY
17
ENTRY
|
@ -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))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue