| Crates.io | version_middleware |
| lib.rs | version_middleware |
| version | 0.2.1 |
| created_at | 2025-04-16 12:31:54.960862+00 |
| updated_at | 2025-04-23 13:41:47.044567+00 |
| description | Custom extractor for Rust Axum to extract the version from an HTTP header X-Version. |
| homepage | |
| repository | https://github.com/nebetoxyz/rust-version-middleware--lib |
| max_upload_size | |
| id | 1636416 |
| size | 25,581 |
Custom extractor for Rust Axum to extract the version from an HTTP header X-Version.
Works ONLY with Rust Axum.
use axum::{routing::get, Router};
use version_middleware::ExtractVersion;
async fn handler(ExtractVersion(version): ExtractVersion) {
println!("Version: {:?}", version);
}
let app = Router::<()>::new().route("/foo", get(handler));
The extracted value is :
trim to clean extra spaces, before and after ;lowercase to standardize and make it more resilient to implementation errors.curl -H "X-Version: v1.0.0" http://api.nebeto.xyz/foo
curl -H "x-version: preView" http://api.nebeto.xyz/foo
curl -H "X-VeRSion: latest" http://api.nebeto.xyz/foo
Will give respectively v1.0.0, preview and latest.
curl http://api.nebeto.xyz/foo
Will give by default latest.
For any question or feature suggestion, you can take a look and open, if necessary, a new discussion.
For any bug, you can take a look to our active issues and open, if necessary, a new issue.