pub fn on<H, T, S>(
filter: MethodFilter,
handler: H,
) -> MethodRouter<S, Infallible>
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));