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"))
|
||||
;; 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))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue