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:
Example:
(router
[\"/api\" {:interceptors [format-body oauth2]}
[\"/users\" {:interceptors [delete]
:handler get-user}]])
Options: Options:
| key | description | key | description
| --------------------------------|------------- | --------------------------------|-------------
| `:reitit.interceptor/transform` | Function of [Interceptor] => [Interceptor] to transform the expanded Interceptors (default: identity). | `: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 | `:reitit.interceptor/registry` | Map of `keyword => IntoInterceptor` to replace keyword references into Interceptor
See router options from [[reitit.core/router]]." Example:
(router
[\"/api\" {:interceptors [format-body oauth2]}
[\"/users\" {:interceptors [delete]
:handler get-user}]])"
([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,15 +47,13 @@
(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/registry` | Map of `keyword => IntoInterceptor` to replace keyword references into Interceptors
| `: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.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)
Example: Example:
@ -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]
@ -112,7 +108,7 @@
| `:executor` | `reitit.interceptor.Executor` for the interceptor chain | `:executor` | `reitit.interceptor.Executor` for the interceptor chain
| `:interceptors` | Optional sequence of interceptors that are always run before any other interceptors, even for the default handler" | `:interceptors` | Optional sequence of interceptors that are always run before any other interceptors, even for the default handler"
([router opts] ([router opts]
(ring-handler router nil opts)) (ring-handler router nil opts))
([router default-handler {:keys [executor interceptors]}] ([router default-handler {:keys [executor interceptors]}]
(let [default-handler (or default-handler (fn ([_]) ([_ respond _] (respond nil)))) (let [default-handler (or default-handler (fn ([_]) ([_ respond _] (respond nil))))
default-queue (->> [default-handler] default-queue (->> [default-handler]

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)