reitit/doc/http/interceptors.md

30 lines
1.3 KiB
Markdown
Raw Normal View History

2018-02-11 17:15:25 +00:00
# Interceptors (WIP)
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
## Current Status
2018-02-11 17:15:25 +00:00
2018-09-02 16:40:25 +00:00
Work-in-progress and considered alpha quality.
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-03 16:44:59 +00:00
[metosin/reitit-http "0.2.0"]
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