tourist/dsl
Route type and HTTP method constructors.
Since: v0.1.0
route-new
(route-new [method : cstr pat : int handler : int] :)
construct a Route from a compiled pattern handle.
| method | HTTP method string: "GET", "POST", "PUT", "DELETE", or "" | |
| for any-method matching | ||
| pat | the route struct's generic payload slot as a raw :int: a | |
| compiled Pattern bridged via (:: p :int) for real routes, 0 | ||
| for middleware, or a sub-app handle for url-map!/cascade! | ||
| items (see tourist/routing). Kept :int precisely because the | ||
| slot is polymorphic across item kinds. | ||
| handler | Turmeric 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
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
route-pattern
(route-pattern [r : int] :)
generic payload slot of a Route.
| r | :int Route handle |
:int -- raw payload slot (a Pattern for real routes, 0 / sub-app handle otherwise)
Since: v0.1.0
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
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 (TUR_APPLY1 dispatch: fat-closure ABI audit, 2026-06-23)
route-free
(route-free [r : int] :)
release a Route handle, its compiled pattern and its handler.
| r | :int Route handle, or 0 (no-op) |
:void
(route-free r)
Since: v0.1.0
get!
(get! [pattern : cstr handler : (fn [Ctx])
declare a GET route.
| pattern | route pattern string, e.g. "/hello/:name" | |
| handler | (fn [Ctx] Response) request handler -- may capture |
:int -- Route handle; consumed by tourist
(get! "/hello/:name"
(fn [req] (text "hi")))
Since: v0.1.0
post!
(post! [pattern : cstr handler : (fn [Ctx])
declare a POST route.
| pattern | route pattern string | |
| handler | (fn [Ctx] Response) request handler -- may capture |
:int -- Route handle
Since: v0.1.0
put!
(put! [pattern : cstr handler : (fn [Ctx])
declare a PUT route.
| pattern | route pattern string | |
| handler | (fn [Ctx] Response) request handler -- may capture |
:int -- Route handle
Since: v0.1.0
delete!
(delete! [pattern : cstr handler : (fn [Ctx])
declare a DELETE route.
| pattern | route pattern string | |
| handler | (fn [Ctx] Response) request handler -- may capture |
:int -- Route handle
Since: v0.1.0
any!
(any! [pattern : cstr handler : (fn [Ctx])
declare a route matching any HTTP method.
| pattern | route pattern string | |
| handler | (fn [Ctx] Response) request handler -- may capture |
:int -- Route handle
(any! "/catch-all" (fn [req] (text "ok")))
Since: v0.1.0
Internal definitions
__route-alloc__route-free-struct__route-drop-handler__handler->int