Document the router options

This commit is contained in:
Tommi Reiman 2018-11-19 21:04:38 +02:00
parent dd6b07aa0f
commit 883a65acca
5 changed files with 33 additions and 43 deletions

View file

@ -129,23 +129,22 @@
(defn router (defn router
"Creates a [[reitit.core/Router]] from raw route data and optionally an options map with "Creates a [[reitit.core/Router]] from raw route data and optionally an options map with
support for Interceptors. See [docs](https://metosin.github.io/reitit/) for details. support for Interceptors. See documentation on [[reitit.core/router]] for available options.
In addition, the following options are available:
Options:
| key | description
| --------------------------------|-------------
| `:reitit.interceptor/transform` | Function or vector of functions of type `[Interceptor] => [Interceptor]` to transform the expanded Interceptors (default: identity).
| `:reitit.interceptor/registry` | Map of `keyword => IntoInterceptor` to replace keyword references into Interceptor
Example: Example:
(router (router
[\"/api\" {:interceptors [format-body oauth2]} [\"/api\" {:interceptors [format-body oauth2]}
[\"/users\" {:interceptors [delete] [\"/users\" {:interceptors [delete]
:handler get-user}]]) :handler get-user}]])"
Options:
| key | description
| --------------------------------|-------------
| `:reitit.interceptor/transform` | Function of [Interceptor] => [Interceptor] to transform the expanded Interceptors (default: identity).
| `:reitit.interceptor/registry` | Map of `keyword => IntoInterceptor` to replace keyword references into Interceptor
See router options from [[reitit.core/router]]."
([data] ([data]
(router data nil)) (router data nil))
([data opts] ([data opts]

View file

@ -122,23 +122,20 @@
(defn router (defn router
"Creates a [[reitit.core/Router]] from raw route data and optionally an options map with "Creates a [[reitit.core/Router]] from raw route data and optionally an options map with
support for Middleware. See [docs](https://metosin.github.io/reitit/) for details. support for Middleware. See documentation on [[reitit.core/router]] for available options.
In addition, the following options are available:
| key | description
| -------------------------------|-------------
| `:reitit.middleware/transform` | Function or vector of functions of type `[Middleware] => [Middleware]` to transform the expanded Middleware (default: identity)
| `:reitit.middleware/registry` | Map of `keyword => IntoMiddleware` to replace keyword references into Middleware
Example: Example:
(router (router
[\"/api\" {:middleware [wrap-format wrap-oauth2]} [\"/api\" {:middleware [wrap-format wrap-oauth2]}
[\"/users\" {:middleware [wrap-delete] [\"/users\" {:middleware [wrap-delete]
:handler get-user}]]) :handler get-user}]])"
Options:
| key | description |
| -------------------------------|-------------|
| `:reitit.middleware/transform` | Function of `[Middleware] => [Middleware]` to transform the expanded Middleware (default: identity).
| `:reitit.middleware/registry` | Map of `keyword => IntoMiddleware` to replace keyword references into Middleware
See other router options from [[reitit.core/router]]."
([data] ([data]
(router data nil)) (router data nil))
([data opts] ([data opts]

View file

@ -40,7 +40,7 @@
(defn router (defn router
"Create a `reitit.core.router` from raw route data and optionally an options map. "Create a `reitit.core.router` from raw route data and optionally an options map.
Enables request coercion. See [[reitit.core.router]] for details on options." Enables request coercion. See [[reitit.core/router]] for details on options."
([raw-routes] ([raw-routes]
(router raw-routes {})) (router raw-routes {}))
([raw-routes opts] ([raw-routes opts]

View file

@ -47,14 +47,12 @@
(defn router (defn router
"Creates a [[reitit.core/Router]] from raw route data and optionally an options map with "Creates a [[reitit.core/Router]] from raw route data and optionally an options map with
support for http-methods and Interceptors. See [docs](https://metosin.github.io/reitit/) support for http-methods and Interceptors. See documentation on [[reitit.core/router]]
for details. for available options. In addition, the following options are available:
Options: | key | description
| ---------------------------------------|-------------
| key | description | | `:reitit.interceptor/transform` | Function or vector of functions of type `[Interceptor] => [Interceptor]` to transform the expanded Interceptors (default: identity)
| ---------------------------------------|-------------|
| `:reitit.interceptor/transform` | Function of `[Interceptor] => [Interceptor]` to transform the expanded Interceptors (default: identity).
| `:reitit.interceptor/registry` | Map of `keyword => IntoInterceptor` to replace keyword references into Interceptors | `:reitit.interceptor/registry` | Map of `keyword => IntoInterceptor` to replace keyword references into Interceptors
| `:reitit.http/default-options-handler` | Default handler for `:options` method in endpoints (default: reitit.ring/default-options-handler) | `:reitit.http/default-options-handler` | Default handler for `:options` method in endpoints (default: reitit.ring/default-options-handler)
@ -65,9 +63,7 @@
[\"/users\" {:get get-user [\"/users\" {:get get-user
:post update-user :post update-user
:delete {:interceptors [delete-i] :delete {:interceptors [delete-i]
:handler delete-user}}]]) :handler delete-user}}]])"
See router options from [[reitit.core/router]] and [[reitit.middleware/router]]."
([data] ([data]
(router data nil)) (router data nil))
([data opts] ([data opts]

View file

@ -67,14 +67,12 @@
(defn router (defn router
"Creates a [[reitit.core/Router]] from raw route data and optionally an options map with "Creates a [[reitit.core/Router]] from raw route data and optionally an options map with
support for http-methods and Middleware. See [docs](https://metosin.github.io/reitit/) support for http-methods and Middleware. See documentation on [[reitit.core/router]] for
for details. available options. In addition, the following options are available:
Options: | key | description
| ---------------------------------------|-------------
| key | description | | `:reitit.middleware/transform` | Function or vector of functions of type `[Middleware] => [Middleware]` to transform the expanded Middleware (default: identity)
| ---------------------------------------|-------------|
| `:reitit.middleware/transform` | Function of `[Middleware] => [Middleware]` to transform the expanded Middleware (default: identity).
| `:reitit.middleware/registry` | Map of `keyword => IntoMiddleware` to replace keyword references into Middleware | `:reitit.middleware/registry` | Map of `keyword => IntoMiddleware` to replace keyword references into Middleware
| `:reitit.ring/default-options-handler` | Default handler for `:options` method in endpoints (default: default-options-handler) | `:reitit.ring/default-options-handler` | Default handler for `:options` method in endpoints (default: default-options-handler)