No matching definitions.

httpd/request

src/httpd/request.tur

read-only accessors for parsed HTTP requests.

Since: H3

defn

req-method

(req-method [req : int] :)

HTTP method of a parsed request.

req:int Request handle

:cstr -- uppercase method string, e.g. "GET", "POST"

(req-method req)  ; => "POST"

Since: H3

defn

req-path

(req-path [req : int] :)

request-target path component (no query string).

req:int Request handle

:cstr -- path beginning with '/', e.g. "/foo/bar"

(req-path req)  ; => "/hello"

Since: H3

defn

req-query

(req-query [req : int] :)

raw query string after '?', or "" if absent.

req:int Request handle

:cstr -- e.g. "name=world&id=1", or "" if the target had no '?'

(req-query req)  ; => "name=world"

Since: H3

defn

req-body

(req-body [req : int] :)

request body bytes (NUL-terminated; length = Content-Length).

req:int Request handle

:cstr -- body content, or "" if the request had no body

(req-body req)  ; => "hello world"

Since: H3

defn

req-header

(req-header [req : int name : cstr] :)

look up a request header by name (case-insensitive).

req:int Request handle
nameheader name, e.g. "Content-Type"

:int -- result<:cstr>: ok(value) if the header is present, err("not found") otherwise. Unwrap with ok-val / err-val.

(let [h (req-header req "Content-Type")]
    (when (ok? h) (println (ok-val h))))

Since: H3