1
0
mirror of https://github.com/actix/examples synced 2024-12-18 00:13:57 +01:00
examples/middleware/request-extensions/README.md

18 lines
631 B
Markdown
Raw Normal View History

2022-02-18 03:18:44 +01:00
# Middleware: Add/Retrieve Request-Local Data
2023-10-30 00:51:05 +01:00
This example showcases a middleware that adds and retrieves request-local data. See also the [middleware guide](https://actix.rs/docs/middleware).
## Usage
2022-02-18 04:36:04 +01:00
```sh
2023-10-30 00:51:05 +01:00
cd middleware/request-extensions
cargo run
```
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