1
0
mirror of https://github.com/actix/examples synced 2024-12-02 18:02:22 +01:00
examples/basics/middleware-ext-mut/README.md
Eric 817c7e1150
Working middleware using extensions_mut (#402)
Co-authored-by: Rob Ede <robjtede@icloud.com>
2021-10-07 04:04:19 +01:00

19 lines
644 B
Markdown

# middleware examples
This example showcases a middleware that adds and retreives request-local data. See also the [Middleware guide](https://actix.rs/docs/middleware/).
## Usage
```bash
cd basics/middleware-ext-mut
cargo run
# Started http server: 127.0.0.1:8080
```
Look in `src/add_msg.rs` to see how it works.
## Routes
- [GET /on](http://localhost:8080/on) - `200 OK` with "hello from middleware" body and console log showing the request passed through the middleware
- [GET /off](http://localhost:8080/off) - `500 Internal Server Error` with "no message found" body and console log showing the request passed through the middleware