http

HTTP server/client module.

get

Sends a GET request to a given URL. If error is true and a status code is not 2xx, it raises an error.

(def (get url . error true))
(type (get string . boolean)
  {"status" number
   "body" string})

post

Sends a POST request to a given URL. If error is true and a status code is not 2xx, it raises an error.

(def (post url body . contentType "text/plain" error true))
(type (post string string . string boolean)
  {"status" number
   "body"   string})

getRequests

Gets incoming HTTP requests as an infinite list.

(def (getRequests address))
(type (getRequests string)
  (def (respond body . status 200))
  (type (respond string . number) nil)
  [{"body" string
    "method" string
    "respond" respond
    "url" string}])