reitit/doc/http/interceptors.md

26 lines
1.2 KiB
Markdown
Raw Normal View History

2018-09-07 21:05:55 +00:00
# Interceptors
2018-02-02 12:48:28 +00:00
2018-09-02 16:40:25 +00:00
Reitit also support for [Pedestal](pedestal.io)-style [interceptors](http://pedestal.io/reference/interceptors) as an alternative to using middleware. Basic interceptor handling is implemented in `reitit.interceptor` package. There is no interceptor executor shipped, but you can use libraries like [Pedestal Interceptor](https://github.com/pedestal/pedestal/tree/master/interceptor) or [Sieppari](https://github.com/metosin/sieppari) to execute the chains.
2018-02-02 12:48:28 +00:00
2018-09-02 16:40:25 +00:00
## Reitit-http
2018-02-02 12:48:28 +00:00
```clj
2018-09-04 15:15:23 +00:00
[metosin/reitit-http "0.2.1"]
2018-09-02 16:40:25 +00:00
```
An module for http-routing using interceptors instead of middleware. Builds on top of the [`reitit-ring`](../ring/ring.md) module. The differences:
2018-02-02 12:48:28 +00:00
2018-09-02 16:40:25 +00:00
* instead of `:middleware`, uses `:interceptors`
* compared to `reitit.http/http-router` takes an extra options map with mandatory key `:executor` (of type `reitit.interceptor/Executor`) and optional top level `:interceptors` - wrapping both routes and default handler.
* optional entry poitn `reitit.http/routing-interceptor` to provide a routing interceptor, to be used with Pedestal.
2018-08-22 17:24:17 +00:00
2018-09-02 16:40:25 +00:00
## Examples
2018-02-02 12:48:28 +00:00
2018-09-02 16:40:25 +00:00
### Sieppari
2018-08-22 17:24:17 +00:00
2018-09-02 16:40:25 +00:00
See code at: https://github.com/metosin/reitit/tree/master/examples/http
2018-08-22 18:55:03 +00:00
### Pedestal
2018-09-02 16:40:25 +00:00
See example at: https://github.com/metosin/reitit/tree/master/examples/pedestal