[−][src]Struct amiya::Context
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]
Ex: Send + Sync + 'static,
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,
Ex: Send,
impl<'x, Ex> Sync for Context<'x, Ex> where
Ex: Sync,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,