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:
David Pedersen
2021-10-24 20:05:16 +00:00
committed by GitHub
parent 0ee7379d4f
commit 7692baf837
57 changed files with 743 additions and 742 deletions
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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()))
})),
));