pub struct Head { /* private fields */ }
Expand description
Middleware to add support for the HTTP HEAD method.
It does this by changing the method to GET and adding a special header (afire::head
).
Once the response is processed by the normal route handler, the middleware will check if the header is present.
If it is, any body data will be discarded and the [Content-Length] header will be added, if it is not already present.
On static responses, the length is already known, but with streaming responses, the stream will be read to the end to get the length (by default).
Implementationsยง
Trait Implementationsยง
sourceยงimpl Middleware for Head
impl Middleware for Head
sourceยงfn pre(&self, req: &mut Request) -> MiddleResult
fn pre(&self, req: &mut Request) -> MiddleResult
Middleware to run Before Routes
sourceยงfn post(&self, req: &Request, res: &mut Response) -> MiddleResult
fn post(&self, req: &Request, res: &mut Response) -> MiddleResult
Middleware to run After Routes
sourceยงfn pre_raw(&self, req: &mut Result<Request>) -> MiddleResult
fn pre_raw(&self, req: &mut Result<Request>) -> MiddleResult
Middleware to run before routes.
Because this is the
raw
version of Middleware::pre
, it is passed a Result
.
The default implementation calls Middleware::pre
if the Result
is Ok
.sourceยงfn post_raw(
&self,
req: Result<Rc<Request>>,
res: &mut Result<Response>
) -> MiddleResult
fn post_raw( &self, req: Result<Rc<Request>>, res: &mut Result<Response> ) -> MiddleResult
Middleware to run after routes.
Because this is the
raw
version of Middleware::post
, it is passed a Result
.
The default implementation calls Middleware::post
if the Result
is Ok
.sourceยงfn end_raw(&self, req: &Result<Request>, res: &Result<Response>)
fn end_raw(&self, req: &Result<Request>, res: &Result<Response>)
Middleware to run after the response has been handled.
Because this is the
raw
version of Middleware::end
, it is passed a Result
.
The default implementation calls Middleware::end
if the Result
is Ok
.Auto Trait Implementationsยง
impl RefUnwindSafe for Head
impl Send for Head
impl Sync for Head
impl Unpin for Head
impl UnwindSafe for Head
Blanket Implementationsยง
sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more