No matching definitions.

tourist/dsl

src/tourist/dsl.tur

Route type and HTTP method constructors.

Since: v0.1.0

defn

route-new

(route-new [method : cstr pat : int handler : int] :)

construct a Route from a compiled pattern handle.

methodHTTP method string: "GET", "POST", "PUT", "DELETE", or ""
for any-method matching
patcompiled pattern handle from router-compile
handlerTurmeric function value (fn [req :int] :int)

:int -- Route handle; free with route-free (which also frees pat)

(route-new "GET" (router-compile "/hello") my-handler)

Since: v0.1.0

defn

route-method

(route-method [r : int] :)

HTTP method string of a Route ("" means any).

r:int Route handle

:cstr -- e.g. "GET", "POST", or "" for any

Since: v0.1.0

defn

route-pattern

(route-pattern [r : int] :)

compiled pattern handle of a Route.

r:int Route handle

:int -- compiled pattern handle (from router-compile)

Since: v0.1.0

defn

route-handler

(route-handler [r : int] :)

raw handler function value of a Route.

r:int Route handle

:int -- Turmeric function value; call via route-call-handler

Since: v0.1.0

defn

route-call-handler

(route-call-handler [r : int req : int] :)

invoke a Route's handler with a request.

r:int Route handle
req:int Request handle (from httpd/request or tourist ctx)

:int -- Response handle returned by the handler

(route-call-handler route req)

Since: v0.1.0

defn

route-free

(route-free [r : int] :)

release a Route handle and its compiled pattern.

r:int Route handle, or 0 (no-op)

:void

(route-free r)

Since: v0.1.0

defn

get!

(get! [pattern : cstr handler : int] :)

declare a GET route.

patternroute pattern string, e.g. "/hello/:name"
handler(fn [req :int] :int) request handler

:int -- Route handle; consumed by tourist

(get! "/hello/:name"
    (fn [req] (text "hi")))

Since: v0.1.0

defn

post!

(post! [pattern : cstr handler : int] :)

declare a POST route.

patternroute pattern string
handler(fn [req :int] :int) request handler

:int -- Route handle

Since: v0.1.0

defn

put!

(put! [pattern : cstr handler : int] :)

declare a PUT route.

patternroute pattern string
handler(fn [req :int] :int) request handler

:int -- Route handle

Since: v0.1.0

defn

delete!

(delete! [pattern : cstr handler : int] :)

declare a DELETE route.

patternroute pattern string
handler(fn [req :int] :int) request handler

:int -- Route handle

Since: v0.1.0

defn

any!

(any! [pattern : cstr handler : int] :)

declare a route matching any HTTP method.

patternroute pattern string
handler(fn [req :int] :int) request handler

:int -- Route handle

(any! "/catch-all" (fn [req] (text "ok")))

Since: v0.1.0

Internal definitions
__route-alloc
__route-free-struct