pub fn on<S, B>(method: MethodFilter, svc: S) -> MethodRouter<S, MethodNotAllowed<S::Error>, B>
where
    S: Service<Request<B>> + Clone,
{
    MethodRouter {
        method,
        svc,
        fallback: MethodNotAllowed::new(),
        _request_body: PhantomData,
    }
}
/// Route requests with the given method to the service.
///
/// # Example
///
/// ```rust
/// use axum::{
///     http::Request,
///     routing::on,
///     Router,
///     routing::{MethodFilter, service_method_routing as service},
/// };
/// use http::Response;
/// use std::convert::Infallible;
/// use hyper::Body;
///
/// let service = tower::service_fn(|request: Request<Body>| async {
///     Ok::<_, Infallible>(Response::new(Body::empty()))
/// });
///
/// // Requests to `POST /` will go to `service`.
/// let app = Router::new().route("/", service::on(MethodFilter::POST, service));
/// # async {
/// # axum::Server::bind(&"".parse().unwrap()).serve(app.into_make_service()).await.unwrap();
/// # };
/// ```
Route requests with the given method to the service.
Route requests with the given method to the service .
pub fn on<S, B>(method: MethodFilter, svc: S) -> MethodRouter<S, MethodNotAllowed<S::Error>, B>
where
    S: Service<Request<B>> + Clone,
{
    MethodRouter {
        method,
        svc,
        fallback: MethodNotAllowed::new(),
        _request_body: PhantomData,
    }
}
pub fn on < S , B > ( method : MethodFilter , svc : S ) -> MethodRouter < S , MethodNotAllowed < S :: Error > , B > where S : Service < Request < B > > + Clone , { MethodRouter { method , svc , fallback : MethodNotAllowed :: new ( ) , _request_body : PhantomData , } }
Route requests with the given method to the service.
Route requests with the given method to the service .
method
MethodFilter
svc
S
example
```rust
use axum::{
http::Request,
routing::on,
Router,
routing::{MethodFilter, service_method_routing as service},
};
use http::Response;
use std::convert::Infallible;
use hyper::Body.

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("/", service::on(MethodFilter::POST, service)).
` ` ` rust use axum :: { http :: Request routing :: on Router routing :: { MethodFilter service_method_routing as service } } ; use http :: Response ; use std :: convert :: Infallible ; use hyper :: Body . 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 ( " / " service :: on ( MethodFilter :: POST service )) .
async {
None
axum::server::bind(&"".parse().unwrap()).serve(app.into_make_service()).await.unwrap();
None
};
None