Function axum::routing::method_routing::on

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