No matching definitions.

tourist/middleware

src/tourist/middleware.tur

Middleware type and middleware chain runner.

Since: v0.1.0

defn

use!

(use! [fn : int] :)

register a middleware function.

fn(fn [req :int] :int) returning option<Response>:
(none) to continue, (some resp) to short-circuit

:int -- middleware handle; consumed by tourist

(use! (fn [req]
          (println (req-path req))
          (none)))

Since: v0.1.0

defn

mw-item?

(mw-item? [item : int] :)

true if an item handle is a middleware, not a route.

item:int item handle (from use!, get!, post!, etc.)

:bool

Since: v0.1.0

defn

mw-call

(mw-call [mw : int req : int] :)

invoke a middleware on a request.

mw:int middleware handle from use!
req:int tourist ctx (request handle)

:int -- option<Response>: 0 = none (continue), non-zero = some(resp)

Since: v0.1.0

defn

mw-chain-run

(mw-chain-run [mws : int req : int] :)

run a cons list of middleware handles in order.

mws:int cons list of middleware handles (0 = empty)
req:int tourist ctx (request handle)

:int -- option<Response>: non-zero some(resp) or 0 for none

(let [opt (mw-chain-run mw-list req)]
    (when (not= opt 0) ...))

Since: v0.1.0

Internal definitions
__mw-cons-head-- head of a Turmeric cons list cell.
__mw-cons-tail-- tail of a Turmeric cons list cell.