[][src]Struct amiya::Context

pub struct Context<'x, Ex> {
    pub req: &'x Request,
    pub resp: &'x mut Response,
    pub ex: &'x mut Ex,
    // some fields omitted
}

The context middleware works on.

Fields

req: &'x Request

The incoming http request, without body. You can use Context::body method to get body.

resp: &'x mut Response

The output http response, you can directly edit it

ex: &'x mut Ex

User defined extra data

Implementations

impl<'x, Ex> Context<'x, Ex> where
    Ex: Send + Sync + 'static, 
[src]

pub async fn next<'_>(&'_ mut self) -> Result[src]

Run all inner middleware, this method drives the middleware system.

Notice that you are not must call this func in all middleware. if you do not call it inner middleware will simply not be executed.

A second call to this method on the same instance will do nothing and directly returns a Ok(()).

pub fn body(&mut self) -> Option<Body>[src]

Get incoming request body data. Only the first call will return Some.

pub fn path(&self) -> &str[src]

The path the next router can match.

It's differ from Context.req.url().path(), path returned by this method will only contains sub paths that haven't matched by any Router middleware.

See examples/router.rs for a example.

pub fn arg<K: AsRef<str>>(&self, name: K) -> Option<&str>[src]

The path argument of name.

Will be set if a router's any item {name} is matched.

See Router - Any Item for more detail.

Examples

See examples/arg.rs for a example.

Auto Trait Implementations

impl<'x, Ex> !RefUnwindSafe for Context<'x, Ex>

impl<'x, Ex> Send for Context<'x, Ex> where
    Ex: Send

impl<'x, Ex> Sync for Context<'x, Ex> where
    Ex: Sync

impl<'x, Ex> Unpin for Context<'x, Ex>

impl<'x, Ex> !UnwindSafe for Context<'x, Ex>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,