mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-26 00:00:23 +02:00
Reorganize method routers for handlers and services (#405)
* Re-organize method routing for handlers * Re-organize method routing for services * changelog
This commit is contained in:
@@ -38,7 +38,7 @@ mod for_handlers {
|
||||
|
||||
mod for_services {
|
||||
use super::*;
|
||||
use crate::service::get;
|
||||
use crate::routing::service_method_router::get;
|
||||
use http::header::HeaderValue;
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
+3
-3
@@ -4,10 +4,10 @@ use crate::error_handling::HandleErrorLayer;
|
||||
use crate::BoxError;
|
||||
use crate::{
|
||||
extract::{self, Path},
|
||||
handler::{any, delete, get, on, patch, post, Handler},
|
||||
handler::Handler,
|
||||
response::IntoResponse,
|
||||
routing::MethodFilter,
|
||||
service, Json, Router,
|
||||
routing::{any, delete, get, on, patch, post, service_method_router as service, MethodFilter},
|
||||
Json, Router,
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use http::{
|
||||
|
||||
+4
-2
@@ -196,16 +196,18 @@ async fn many_ors() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn services() {
|
||||
use crate::routing::service_method_router::get;
|
||||
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/foo",
|
||||
crate::service::get(service_fn(|_: Request<Body>| async {
|
||||
get(service_fn(|_: Request<Body>| async {
|
||||
Ok::<_, Infallible>(Response::new(Body::empty()))
|
||||
})),
|
||||
)
|
||||
.or(Router::new().route(
|
||||
"/bar",
|
||||
crate::service::get(service_fn(|_: Request<Body>| async {
|
||||
get(service_fn(|_: Request<Body>| async {
|
||||
Ok::<_, Infallible>(Response::new(Body::empty()))
|
||||
})),
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user