Rename EmptyRouter to MethodNotAllowed (#411)

It is no longer needed in `Router` so can be changed to always return
`403 Method Not Allowed`.
This commit is contained in:
David Pedersen
2021-10-25 23:28:22 +02:00
committed by GitHub
parent 59819e42bf
commit e43bdf0ecf
6 changed files with 56 additions and 67 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ use crate::{
body::{box_body, BoxBody},
extract::{FromRequest, RequestParts},
response::IntoResponse,
routing::{EmptyRouter, MethodRouter},
routing::{MethodNotAllowed, MethodRouter},
BoxError,
};
use async_trait::async_trait;
@@ -78,7 +78,7 @@ pub trait Handler<B, T>: Clone + Send + Sized + 'static {
/// ```
fn layer<L>(self, layer: L) -> Layered<L::Service, T>
where
L: Layer<MethodRouter<Self, B, T, EmptyRouter>>,
L: Layer<MethodRouter<Self, B, T, MethodNotAllowed>>,
{
Layered::new(layer.layer(crate::routing::any(self)))
}