Trait gotham::middleware::NewMiddleware[][src]

pub trait NewMiddleware: Sync + RefUnwindSafe {
    type Instance: Middleware;
    fn new_middleware(&self) -> Result<Self::Instance>;
}

A type which is used to spawn new Middleware values. When implementing a Middleware, this defines how instances of the Middleware are created.

This can be derived by Middleware that implement Clone, and will result in the following implementation:

struct MyMiddleware;

impl NewMiddleware for MyMiddleware {
    type Instance = Self;

    fn new_middleware(&self) -> anyhow::Result<Self::Instance> {
        Ok(self.clone())
    }
}

Associated Types

type Instance: Middleware[src]

The type of Middleware created by the NewMiddleware.

Loading content...

Required methods

fn new_middleware(&self) -> Result<Self::Instance>[src]

Create and return a new Middleware value.

Loading content...

Implementors

impl NewMiddleware for CookieParser[src]

NewMiddleware trait implementation.

type Instance = Self

fn new_middleware(&self) -> Result<Self::Instance>[src]

Clones the current middleware to a new instance.

impl NewMiddleware for RequestLogger[src]

Implementation of NewMiddleware is required for Gotham middleware.

This will simply dereference the internal state, rather than deriving NewMiddleware which will clone the structure - should be cheaper for repeated calls.

type Instance = Self

fn new_middleware(&self) -> Result<Self::Instance>[src]

Returns a new middleware to be used to serve a request.

impl NewMiddleware for SimpleLogger[src]

Implementation of NewMiddleware is required for Gotham middleware.

This will simply dereference the internal state, rather than deriving NewMiddleware which will clone the structure - should be cheaper for repeated calls.

type Instance = Self

fn new_middleware(&self) -> Result<Self::Instance>[src]

Returns a new middleware to be used to serve a request.

impl NewMiddleware for SecurityMiddleware[src]

NewMiddleware trait implementation.

type Instance = Self

fn new_middleware(&self) -> Result<Self::Instance>[src]

Clones the current middleware to a new instance.

impl NewMiddleware for RequestTimer[src]

NewMiddleware trait implementation.

type Instance = Self

fn new_middleware(&self) -> Result<Self::Instance>[src]

Clones the current middleware to a new instance.

impl<B, T> NewMiddleware for NewSessionMiddleware<B, T> where
    B: NewBackend,
    T: Default + Serialize + for<'de> Deserialize<'de> + Send + 'static, 
[src]

impl<T> NewMiddleware for StateMiddleware<T> where
    T: Clone + RefUnwindSafe + StateData + Sync
[src]

NewMiddleware trait implementation.

type Instance = Self

fn new_middleware(&self) -> Result<Self::Instance>[src]

Clones the current middleware to a new instance.

Loading content...