Function axum::handler::on[][src]

pub fn on<H, B, T>(
    method: MethodFilter,
    handler: H
) -> OnMethod<IntoService<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, routing::MethodFilter, prelude::*};

async fn handler() {}

// Requests to `POST /` will go to `handler`.
let app = route("/", on(MethodFilter::Post, handler));