reitit/doc/advanced/configuring_routers.md

20 lines
1.4 KiB
Markdown
Raw Normal View History

2017-12-10 16:08:00 +00:00
# Configuring Routers
2017-09-14 13:33:36 +00:00
2017-12-28 08:44:35 +00:00
Routers can be configured via options. The following options are available for the `reitit.core/router`:
2017-09-14 13:33:36 +00:00
2019-06-09 17:46:20 +00:00
| key | description
|--------------|-------------
2022-08-11 01:20:35 +00:00
| `:path` | Base-path for routes
| `:routes` | Initial resolved routes (default `[]`)
| `:data` | Initial route data (default `{}`)
| `:spec` | clojure.spec definition for a route data, see `reitit.spec` on how to use this
| `:syntax` | Path-parameter syntax as keyword or set of keywords (default #{:bracket :colon})
| `:expand` | Function of `arg opts => data` to expand route arg to route data (default `reitit.core/expand`)
| `:coerce` | Function of `route opts => route` to coerce resolved route, can throw or return `nil`
| `:meta-merge-fn` | Function which follows the signature of `meta-merge.core/meta-merge`, useful for when you want to have more control over the meta merging
| `:compile` | Function of `route opts => result` to compile a route handler
| `:validate` | Function of `routes opts => ()` to validate route (data) via side-effects
| `:conflicts` | Function of `{route #{route}} => ()` to handle conflicting routes
| `:exception` | Function of `Exception => Exception ` to handle creation time exceptions (default `reitit.exception/exception`)
| `:router` | Function of `routes opts => router` to override the actual router implementation