1
0
mirror of https://github.com/actix/examples synced 2024-11-30 17:14:35 +01:00
examples/guards
2023-01-02 20:33:43 +00:00
..
src reduce futures dep 2022-03-06 00:15:19 +00:00
Cargo.toml move a couple more things to workspace deps 2023-01-02 20:33:43 +00:00
README.md format markdown 2022-03-06 00:43:10 +00:00

guards

Shows how to set up custom routing guards.

  • Routing different API versions using a header instead of path.

Usage

Running The Server

cd guards
cargo run --bin=guards

Available Routes

GET /api/hello

Requires the Accept-Version header to be present and set to 1 or 2.

Using HTTPie:

http :8080/api/hello Accept-Version:1

Using cURL:

curl 'localhost:8080/api/hello' -H 'accept-version: 1'