Module warp::reply [−][src]
Reply to requests.
A Reply
is a type that can be converted into an HTTP
response to be sent to the client. These are typically the successful
counterpart to a rejection.
The functions in this module are helpers for quickly creating a reply.
Besides them, you can return a type that implements Reply
. This
could be any of the following:
http::Response<impl Into<hyper::Body>
String
&'static str
http::StatusCode
Example
use warp::{Filter, http::Response}; // Returns an empty `200 OK` response. let empty_200 = warp::any().map(warp::reply); // Returns a `200 OK` response with custom header and body. let custom = warp::any().map(|| { Response::builder() .header("my-custom-header", "some-value") .body("and a custom body") }); // GET requests return the empty 200, POST return the custom. let routes = warp::get2().and(empty_200) .or(warp::post2().and(custom));
Traits
Reply |
Types that can be converted into a |
Functions
json |
Convert the value into a |
reply |
Returns an empty |