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