mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-04 13:27:39 +03:00
no need for generics
This commit is contained in:
parent
cd79c0e997
commit
2299b75a74
3 changed files with 11 additions and 16 deletions
|
@ -186,7 +186,7 @@ pub trait ServiceFactory {
|
|||
/// Errors produced while building a service.
|
||||
type InitError;
|
||||
|
||||
/// The future of the `Service` instance.
|
||||
/// The future of the `ServiceFactory` instance.
|
||||
type Future: Future<Output = Result<Self::Service, Self::InitError>>;
|
||||
|
||||
/// Create and return a new service value asynchronously.
|
||||
|
|
|
@ -30,9 +30,8 @@ use crate::web::dev::{WebRequest, WebResponse};
|
|||
/// }
|
||||
/// ```
|
||||
#[derive(Clone)]
|
||||
pub struct DefaultHeaders<E> {
|
||||
pub struct DefaultHeaders {
|
||||
inner: Rc<Inner>,
|
||||
_t: PhantomData<E>,
|
||||
}
|
||||
|
||||
struct Inner {
|
||||
|
@ -40,21 +39,20 @@ struct Inner {
|
|||
headers: HeaderMap,
|
||||
}
|
||||
|
||||
impl<E> Default for DefaultHeaders<E> {
|
||||
impl Default for DefaultHeaders {
|
||||
fn default() -> Self {
|
||||
DefaultHeaders {
|
||||
inner: Rc::new(Inner {
|
||||
ct: false,
|
||||
headers: HeaderMap::new(),
|
||||
}),
|
||||
_t: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E> DefaultHeaders<E> {
|
||||
impl DefaultHeaders {
|
||||
/// Construct `DefaultHeaders` middleware.
|
||||
pub fn new() -> DefaultHeaders<E> {
|
||||
pub fn new() -> DefaultHeaders {
|
||||
DefaultHeaders::default()
|
||||
}
|
||||
|
||||
|
@ -92,7 +90,7 @@ impl<E> DefaultHeaders<E> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S, E> Transform<S> for DefaultHeaders<E>
|
||||
impl<S, E> Transform<S> for DefaultHeaders
|
||||
where
|
||||
S: Service<Request = WebRequest<E>, Response = WebResponse>,
|
||||
S::Future: 'static,
|
||||
|
|
|
@ -77,9 +77,8 @@ use crate::web::HttpResponse;
|
|||
///
|
||||
/// `%{FOO}e` os.environ['FOO']
|
||||
///
|
||||
pub struct Logger<Err> {
|
||||
pub struct Logger {
|
||||
inner: Rc<Inner>,
|
||||
_t: PhantomData<Err>,
|
||||
}
|
||||
|
||||
struct Inner {
|
||||
|
@ -87,15 +86,14 @@ struct Inner {
|
|||
exclude: HashSet<String>,
|
||||
}
|
||||
|
||||
impl<Err> Logger<Err> {
|
||||
impl Logger {
|
||||
/// Create `Logger` middleware with the specified `format`.
|
||||
pub fn new(format: &str) -> Logger<Err> {
|
||||
pub fn new(format: &str) -> Logger {
|
||||
Logger {
|
||||
inner: Rc::new(Inner {
|
||||
format: Format::new(format),
|
||||
exclude: HashSet::new(),
|
||||
}),
|
||||
_t: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +107,7 @@ impl<Err> Logger<Err> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<Err> Default for Logger<Err> {
|
||||
impl Default for Logger {
|
||||
/// Create `Logger` middleware with format:
|
||||
///
|
||||
/// ```ignore
|
||||
|
@ -121,12 +119,11 @@ impl<Err> Default for Logger<Err> {
|
|||
format: Format::default(),
|
||||
exclude: HashSet::new(),
|
||||
}),
|
||||
_t: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, Err> Transform<S> for Logger<Err>
|
||||
impl<S, Err> Transform<S> for Logger
|
||||
where
|
||||
S: Service<Request = WebRequest<Err>, Response = WebResponse>,
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue