1
0
mirror of https://github.com/actix/examples synced 2024-11-23 14:31:07 +01:00
examples/middleware/request-extensions
2023-10-29 23:51:05 +00:00
..
src chore: rename middleware dirs 2023-10-29 23:51:05 +00:00
Cargo.toml chore: rename middleware dirs 2023-10-29 23:51:05 +00:00
README.md chore: rename middleware dirs 2023-10-29 23:51:05 +00:00

Middleware: Add/Retrieve Request-Local Data

This example showcases a middleware that adds and retrieves request-local data. See also the middleware guide.

Usage

cd middleware/request-extensions
cargo run

Look in src/add_msg.rs to see how it works.

Routes

  • GET /on - 200 OK with "hello from middleware" body and console log showing the request passed through the middleware
  • GET /off - 500 Internal Server Error with "no message found" body and console log showing the request passed through the middleware