pub type Middleware( before_req, before_resp, after_req, after_resp, ) = fn(Service(before_req, before_resp)) -> Service(after_req, after_resp)
pub fn map_response_body(service: fn(Request(a)) -> Response(b), with mapper: fn( b, ) -> c) -> fn(Request(a)) -> Response(c)
A middleware that transform the response body returned by the service using a given function.
pub fn method_override(service: fn(Request(a)) -> Response(b)) -> fn( Request(a), ) -> Response(b)
A middleware that overrides an incoming POST request with a method given in
_method query paramerter. This is useful as web browsers
typically only support GET and POST requests, but our application may
expect other HTTP methods that are more semantically correct.
The methods PUT, PATCH, and DELETE are accepted for overriding, all others are ignored.
_method query paramerter can be specified in a HTML form like so:
<form method="POST" action="/item/1?_method=DELETE"> <button type="submit">Delete item</button> </form>