io.randomseed.utils.reitit.http

added in 1.0.5

Random utils, Reitit support functions.

Matchable

protocol

The Identifiable protocol describes operations on path or route ID/name data.

members

match

(match r)(match id r)(match id params r)

Converts or coerces the given argument to a Match.

match?

(match? r)

Returns true if the given argument is a Match object.

path

(path req-or-match)(path req-or-router name-or-path)(path req-or-router name-or-path path-params)

For the given request map, a Reitit match object, or a Reitit router, returns the path of a route for the current path or for a path specified by its unique identifier or a string. Optionally path params map can be given if the path supports path params.

req-or-route-param

(req-or-route-param req-or-match param)(req-or-route-param req-or-router param default)

Works like io.randomseed.utils.reitit.http/route-data-param but first tries to get the parameter from a request map, if the first argument is a request map.

Routable

protocol

The Routable protocol describes operations on route-related data.

members

router

(router r)

Converts or coerces the given argument to a Router.

router?

(router? r)

Returns true if the given argument is a Router object.

route-conflicting?

(route-conflicting? req-or-match)(route-conflicting? req-or-router name-or-path)(route-conflicting? req-or-router name-or-path path-params)

For the given request map, a Reitit match object, or a Reitit router, returns true if a route (for the path specified by its unique identifier or a string) is marked as conflicting. Optionally path params map can be given if the path supports path params.

route-data

(route-data req-or-match)(route-data req-or-router name-or-path)(route-data req-or-router name-or-path path-params)

For the given request map, a Reitit match object, or a Reitit router, returns a route data map for the current path or for the path specified by its unique identifier or a string. Optionally path params map can be given if the path supports path params.

route-data-param

(route-data-param req-or-match param)(route-data-param req-or-router param name-or-path)(route-data-param req-or-router param name-or-path path-params)

For the given request map, a Reitit match object, or a Reitit router, returns the requested parameter of a route data map for the current path or for the path specified by its unique identifier or a string. Optionally path params map can be given if the path supports path params.

route-handler

(route-handler req-or-match)(route-handler req-or-router name-or-path)(route-handler req-or-router name-or-path path-params)

For the given request map, a Reitit match object, or a Reitit router, returns a handler of a route for the path specified by its unique identifier or a string. Optionally path params map can be given if the path supports path params.

route-middleware

(route-middleware req-or-match)(route-middleware req-or-router name-or-path)(route-middleware req-or-router name-or-path path-params)

For the given request map, a Reitit match object, or a Reitit router, returns a middleware chain of a route for the path specified by its unique identifier or a string. Optionally path params map can be given if the path supports path params.

route-name

(route-name req-or-match)(route-name req-or-router name-or-path)(route-name req-or-router name-or-path path-params)

For the given request map, a Reitit match object, or a Reitit router, returns a unique name of a route for the path specified by its unique identifier or a string. Optionally path params map can be given if the path supports path params.