use httpz::{
http::{Method, Response, StatusCode},
GenericEndpoint, Request,
};
#[cfg(feature = "axum")]
#[tokio::main]
async fn main() {
let endpoint = GenericEndpoint::new(
"/*any",
[Method::GET, Method::POST],
|_req: Request| async move {
Ok(Response::builder()
.status(StatusCode::OK)
.header("Content-Type", "text/html")
.body(b"Hello httpz World!".to_vec())?)
},
);
let app = axum::Router::new().nest("/", endpoint.axum());
let addr = "[::]:9000".parse::<std::net::SocketAddr>().unwrap(); println!("Axum listening on http://{}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
}