No matching definitions.

tourist/helpers

src/tourist/helpers.tur

response shorthand builders.

Since: v0.1.0

defn

text

(text [body : cstr] :)

build a 200 text/plain response.

bodyresponse body string

:int -- Response handle with status 200 and Content-Type text/plain

(text "Hello, world!")

Since: v0.1.0

defn

html

(html [body : cstr] :)

build a 200 text/html response.

bodyresponse body string (HTML markup)

:int -- Response handle with status 200 and Content-Type text/html

(html "<p>Hello</p>")

Since: v0.1.0

defn

json-body

(json-body [body : cstr] :)

build a 200 application/json response.

bodyresponse body string (JSON-encoded value)

:int -- Response handle with status 200 and Content-Type application/json

(json-body "{\"ok\":true}")

Since: v0.1.0

defn

redirect

(redirect [path : cstr] :)

build a 302 redirect response.

pathtarget URL or path, e.g. "/new-path"

:int -- Response handle with status 302 and Location header set

(redirect "/new-path")

Since: v0.1.0

defn

status

(status [code : int resp : int] :)

override the HTTP status code of an existing response.

codenew HTTP status code, e.g. 201, 204, 422
resp:int Response handle to modify

:int -- the same Response handle with the updated status code

(status 201 (text "created"))

Since: v0.1.0