A simple subdomain parser middleware for Warp web server framework with nano second processing time. 🚀🚀
rust
... warp route
.and(warp_subdomain::with_subdomain)`
... route handler
```rust use std::collections::HashMap; use std::sync::Arc;
use warp::Filter;
use warpsubdomain::withsubdomain;
async fn query(
query: HashMap
Ok(warp::reply::with_status(
subdomain_0.unwrap().to_string(),
warp::http::StatusCode::FOUND,
))
}
async fn main() {
let route = warp::path!("home")
.and(warp::get())
.and(warp::query::
warp::serve(route).run(([127, 0, 0, 1], 3030)).await
}
```
rust
/// If host eg. super-alloy.api.cilen.com.
/// This middleware will return
vec!["super-alloy", "api"]
rust
/// This middleware also works for localhost that have port in host header.
/// eg. api.localhost:3999
This middlewares will return value with type Arc<Vec<String>>