Function axum::handler::on [−][src]
pub fn on<H, B, T>(
method: MethodFilter,
handler: H
) -> OnMethod<H, B, T, EmptyRouter> where
H: Handler<B, T>,
Expand description
Route requests with the given method to the handler.
Example
use axum::{
handler::on,
Router,
routing::MethodFilter,
};
async fn handler() {}
// Requests to `POST /` will go to `handler`.
let app = Router::new().route("/", on(MethodFilter::POST, handler));