Function catalyzer::internals::crates::axum::routing::method_routing::on_service
pub fn on_service<T, S>(
filter: MethodFilter,
svc: T
) -> MethodRouter<S, <T as Service<Request<Body>>>::Error>
Expand description
Route requests with the given method to the service.
§Example
use axum::{
extract::Request,
routing::on,
Router,
body::Body,
routing::{MethodFilter, on_service},
};
use http::Response;
use std::convert::Infallible;
let service = tower::service_fn(|request: Request| async {
Ok::<_, Infallible>(Response::new(Body::empty()))
});
// Requests to `POST /` will go to `service`.
let app = Router::new().route("/", on_service(MethodFilter::POST, service));