http
Jump to function (18) ›
- http/emit-response
- http/files-from-globals
- http/headers-from-server
- http/request
- http/request-from-globals
- http/request-from-globals-args
- http/request-from-map
- http/request?
- http/response
- http/response-from-map
- http/response-from-string
- http/response?
- http/uploaded-file
- http/uploaded-file?
- http/uri
- http/uri-from-globals
- http/uri-from-string
- http/uri?
http/emit-response#
(emit-response response)
Emits the response by sending headers and outputting the body.
Example:
(emit-response (response-from-string "Hello World")) ; => nil
http/files-from-globals#
(files-from-globals & [files])
Extracts the files from $_FILES and normalizes them to a map of "uploaded-file".
Example:
(files-from-globals) ; => {:avatar (uploaded-file "/tmp/phpYzdqkD" 1024 0 "photo.jpg" "image/jpeg")}
http/headers-from-server#
(headers-from-server & [server])
Extracts all headers from the $_SERVER variable.
Example:
(headers-from-server) ; => {:host "example.com" :content-type "application/json"}
http/request#
(request method uri headers parsed-body query-params cookie-params server-params uploaded-files version attributes)
Creates a new request struct.
http/request-from-globals#
(request-from-globals)
Extracts a request from $_SERVER, $_GET, $_POST, $_COOKIE and $_FILES.
Example:
(request-from-globals) ; => (request "GET" (uri ...) {...} nil {...} {...} {...} {...} "1.1" {})
http/request-from-globals-args#
(request-from-globals-args server get-parameter post-parameter cookies files)
Extracts a request from args.
Example:
(request-from-globals-args php/$_SERVER php/$_GET php/$_POST php/$_COOKIE php/$_FILES) ; => (request "GET" (uri ...) {...} nil {...} {...} {...} {...} "1.1" {})
http/request-from-map#
(request-from-map {:method method, :version version, :uri uri, :headers headers, :parsed-body parsed-body, :query-params query-params, :cookie-params cookie-params, :server-params server-params, :uploaded-files uploaded-files, :attributes attributes})
Creates a request struct from a map with optional keys :method, :uri, :headers, etc.
Example:
(request-from-map {:method "POST" :uri "https://api.example.com/users"}) ; => (request "POST" (uri ...) {} nil {} {} {} [] "1.1" {})
http/request?#
(request? x)
Checks if x is an instance of the request struct.
http/response#
(response status headers body version reason)
Creates a new response struct.
http/response-from-map#
(response-from-map {:status status, :headers headers, :body body, :version version, :reason reason})
Creates a response struct from a map with optional keys :status, :headers, :body, :version, and :reason.
Example:
(response-from-map {:status 200 :body "Hello World"}) ; => (response 200 {} "Hello World" "1.1" "OK")
http/response-from-string#
(response-from-string s)
Create a response from a string.
Example:
(response-from-string "Hello World") ; => (response 200 {} "Hello World" "1.1" "OK")
http/response?#
(response? x)
Checks if x is an instance of the response struct.
http/uploaded-file#
(uploaded-file tmp-file size error-status client-filename client-media-type)
Creates a new uploaded-file struct.
http/uploaded-file?#
(uploaded-file? x)
Checks if x is an instance of the uploaded-file struct.
http/uri#
(uri scheme userinfo host port path query fragment)
Creates a new uri struct.
http/uri-from-globals#
(uri-from-globals & [server])
Extracts the URI from the $_SERVER variable.
Example:
(uri-from-globals) ; => (uri "https" nil "example.com" 443 "/path" "foo=bar" nil)
http/uri-from-string#
(uri-from-string url)
Create a uri struct from a string.
Example:
(uri-from-string "https://example.com/path?foo=bar") ; => (uri "https" nil "example.com" nil "/path" "foo=bar" nil)
http/uri?#
(uri? x)
Checks if x is an instance of the uri struct.