Function axum::routing::on[][src]

pub fn on<H, T, B>(
    filter: MethodFilter,
    handler: H
) -> MethodRouter<B, Infallible> where
    H: Handler<T, B>,
    B: Send + 'static,
    T: 'static, 
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));