Struct tsukuyomi::Context [−][src]
pub struct Context { /* fields omitted */ }
Contextural values used by handlers during processing an incoming HTTP request.
The values of this type are created at calling AppService::call
, and used until the future
created at its time is completed.
Methods
impl Context
[src]
impl Context
pub fn is_set() -> bool
[src]
pub fn is_set() -> bool
Returns 'true' if the reference to a Context
is set to the scoped TLS.
If this function returns 'false', the function Context::with
will panic.
pub fn with<R>(
f: impl FnOnce(&Context) -> R
) -> R
[src]
pub fn with<R>(
f: impl FnOnce(&Context) -> R
) -> R
Executes a closure by using a reference to a Context
from the scoped TLS and returns its
result.
Panics
This function will panic if any reference to Context
is set to the scoped TLS.
Do not call this function outside the manage of the framework.
pub fn request(&self) -> &Request<RequestBody>
[src]
pub fn request(&self) -> &Request<RequestBody>
Returns a reference to the value of Request
contained in this context.
pub fn header<H>(&self) -> Result<Option<H>, Error> where
H: Header,
[src]
pub fn header<H>(&self) -> Result<Option<H>, Error> where
H: Header,
Parses a header field in the request to a value of H
.
pub fn with_route<R>(
&self,
f: impl FnOnce(&Route) -> R
) -> R
[src]
pub fn with_route<R>(
&self,
f: impl FnOnce(&Route) -> R
) -> R
Runs a closure using the reference to a Route
matched to the incoming request.
pub fn params(&self) -> Params
[src]
pub fn params(&self) -> Params
Returns a proxy object for accessing parameters extracted by the router.
Returns a proxy object for managing the value of Cookie entries.
This function will perform parsing when called at first, and returns an Err
if the value of header field is invalid.
Methods from Deref<Target = Request<RequestBody>>
pub fn method(&self) -> &Method
[src]
pub fn method(&self) -> &Method
Returns a reference to the associated HTTP method.
Examples
let request: Request<()> = Request::default(); assert_eq!(*request.method(), Method::GET);
pub fn uri(&self) -> &Uri
[src]
pub fn uri(&self) -> &Uri
Returns a reference to the associated URI.
Examples
let request: Request<()> = Request::default(); assert_eq!(*request.uri(), *"/");
pub fn version(&self) -> Version
[src]
pub fn version(&self) -> Version
Returns the associated version.
Examples
let request: Request<()> = Request::default(); assert_eq!(request.version(), Version::HTTP_11);
pub fn headers(&self) -> &HeaderMap<HeaderValue>
[src]
pub fn headers(&self) -> &HeaderMap<HeaderValue>
Returns a reference to the associated header field map.
Examples
let request: Request<()> = Request::default(); assert!(request.headers().is_empty());
pub fn extensions(&self) -> &Extensions
[src]
pub fn extensions(&self) -> &Extensions
Returns a reference to the associated extensions.
Examples
let request: Request<()> = Request::default(); assert!(request.extensions().get::<i32>().is_none());
ⓘImportant traits for &'a mut Rpub fn body(&self) -> &T
[src]
pub fn body(&self) -> &T
Returns a reference to the associated HTTP body.
Examples
let request: Request<String> = Request::default(); assert!(request.body().is_empty());
Trait Implementations
impl Debug for Context
[src]
impl Debug for Context
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Deref for Context
[src]
impl Deref for Context
type Target = Request<RequestBody>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
fn deref(&self) -> &Self::Target
Dereferences the value.
impl ContextSessionExt for Context
[src]
impl ContextSessionExt for Context