mirror of
https://github.com/metosin/reitit.git
synced 2025-12-16 16:01:11 +00:00
Fix typos & unfinished sentences
This commit is contained in:
parent
01c97729bd
commit
4ea0dc2600
2 changed files with 7 additions and 7 deletions
|
|
@ -7,7 +7,7 @@ Reitit ships with several different implementations for the `Router` protocol, o
|
|||
| `:linear-router` | Matches the routes one-by-one starting from the top until a match is found. Works with any kind of routes. Slow, but works with all route trees.
|
||||
| `:lookup-router` | Fast router, uses hash-lookup to resolve the route. Valid if no paths have path or catch-all parameters and there are no [Route conflicts](../basics/route_conflicts.md).
|
||||
| `:mixed-router` | Creates internally a `:prefix-tree-router` and a `:lookup-router` and used them to effectively get best-of-both-worlds. Valid only if there are no [Route conflicts](../basics/route_conflicts.md).
|
||||
| `::single-static-path-router` | Super fast router: sting-matches the route. Valid only if there is one static route.
|
||||
| `:single-static-path-router` | Super fast router: sting-matches the route. Valid only if there is one static route.
|
||||
| `:prefix-tree-router` | Router that creates a [prefix-tree](https://en.wikipedia.org/wiki/Radix_tree) out of an route table. Much faster than `:linear-router`. Valid only if there are no [Route conflicts](../basics/route_conflicts.md).
|
||||
|
||||
The router name can be asked from the router:
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
# Data-driven Middleware
|
||||
|
||||
Ring [defines middleware](https://github.com/ring-clojure/ring/wiki/Concepts#middleware) as a function of type `handler & opts => request => response`. It's easy to undrstand and enables great performance, but makes the middleware-chain opaque, making things like documentation and debugging hard.
|
||||
Ring [defines middleware](https://github.com/ring-clojure/ring/wiki/Concepts#middleware) as a function of type `handler & args => request => response`. It's easy to undrstand and enables great performance. Still, in the end - the middleware-chain is just a opaque function, making things like documentation and debugging hard.
|
||||
|
||||
Reitit does things bit differently:
|
||||
|
||||
1. middleware is defined as a vector (of middleware) enabling the chain to be malipulated before turned into the optimized runtime chain.
|
||||
2. middleware can be defined as first-class data entries
|
||||
1. Middleware is defined as a vector (of middleware) enabling the chain to be malipulated before turned into the runtime middleware function.
|
||||
2. Middleware can be defined as first-class data entries
|
||||
|
||||
### Middleware as data
|
||||
|
||||
Everything that is defined inside the `:middleware` vector in the route data is coerced into `reitit.ring.middleware/Middleware` Records with the help of `reitit.ring.middleware/IntoMiddleware` Protocol. By default, it transforms functions, maps and `Middleware` records. For the actual
|
||||
All values in the `:middleware` vector in the route data are coerced into `reitit.ring.middleware/Middleware` Records with using the `reitit.ring.middleware/IntoMiddleware` Protocol. By default, functions, maps and `Middleware` records are allowed.
|
||||
|
||||
Records can have arbitrary keys, but the default keys have a special purpose:
|
||||
Records can have arbitrary keys, but the following keys have a special purpose:
|
||||
|
||||
| key | description |
|
||||
| ------------|-------------|
|
||||
|
|
@ -21,7 +21,7 @@ Records can have arbitrary keys, but the default keys have a special purpose:
|
|||
|
||||
Middleware Records are accessible in their raw form in the compiled route results, thus available for inventories, creating api-docs etc.
|
||||
|
||||
For the actual request processing, the Records are unwrapped into normal functions, yielding zero runtime penalty.
|
||||
For the actual request processing, the Records are unwrapped into normal functions and composed into a middleware function chain, yielding zero runtime penalty.
|
||||
|
||||
### Creating Middleware
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue