better docs

This commit is contained in:
Tommi Reiman 2018-09-09 21:50:23 +03:00
parent dc3adc025e
commit b50c03a0b9
3 changed files with 9 additions and 7 deletions

View file

@ -4,7 +4,7 @@
[metosin/reitit-interceptors "0.2.1"]
```
Just like the [ring default middleware](../ring/default_middleware.md), but for interceptors. The default interceptors are:
Just like the [ring default middleware](../ring/default_middleware.md), but for interceptors.
### Parameters handling
* `reitit.http.interceptors.parameters/parameters-interceptor`

View file

@ -1,10 +1,10 @@
# Pedestal
[Pedestal](http://pedestal.io/) is a well known interceptor implmementation for Clojure. To use `reitit-http` with it, we need to change the default routing interceptor into a new one. Currently, there isn't a separate Pedestal-module in reitit, but the examples have the example code how to do this.
[Pedestal](http://pedestal.io/) is a well known interceptor-based web framework for Clojure. To use `reitit-http` with Pedestal, we need to change the default routing interceptor into a new one. Examples projects show how to do this.
## Caveat
`reitit-http` defines Interceptors as `reitit.interceptor/Interceptor`. Compared to Pedestal (2-arity), reitit uses a simplified (1-arity) model for handling errors, described in the [Sieppari README](https://github.com/metosin/sieppari#differences-to-pedestal).
`reitit-http` defines Interceptors as `reitit.interceptor/Interceptor`. Compared to Pedestal 2-arity error handlers, reitit uses a simplified (1-arity) handlers. Differences in error handling are described in the [Sieppari README](https://github.com/metosin/sieppari#differences-to-pedestal).
* you can use any [pedestal-style interceptor](http://pedestal.io/reference/interceptors) within reitit router (as Pedestal is executing those anyway)
* you can use any reitit-style interceptor that doesn't have `:error`-stage defined

View file

@ -4,11 +4,13 @@
[metosin/reitit-sieppari "0.2.1"]
```
[Sieppari](https://github.com/metosin/sieppari) is a new and fast interceptor implementation with pluggable async ([core.async](https://github.com/clojure/core.async), [Manifold](https://github.com/ztellman/manifold) and [Promesa](http://funcool.github.io/promesa/latest)).
[Sieppari](https://github.com/metosin/sieppari) is a new and fast interceptor implementation for Clojure, with pluggable async supporting [core.async](https://github.com/clojure/core.async), [Manifold](https://github.com/ztellman/manifold) and [Promesa](http://funcool.github.io/promesa/latest).
To use Sieppari with `reitit-http`, there is `reitit-sieppari` module, which has an `reitit.interceptor.Executor` implementation for Sieppari. All reitit interceptors use the Sieppari Interceptor model, so they work seamlesly together.
To use Sieppari with `reitit-http`, we need to attach a `reitit.interceptor.sieppari/executor` to a `http-router` to compile and execute the interceptor chains. Reitit and Sieppari share the same interceptor model, so all reitit default interceptors work seamlesly together.
Synchronous Ring:
We can use both syncronous ring and [async-ring](https://www.booleanknot.com/blog/2016/07/15/asynchronous-ring.html) with Sieppari.
## Synchronous Ring
```clj
(require '[reitit.http :as http])
@ -43,7 +45,7 @@ Synchronous Ring:
;=> {:status 200, :body "pong"}
```
Ring-async:
## Async-ring
```clj
(let [respond (promise)]