pub trait Reply: BoxedReply + Send {
// Required method
fn into_response(self) -> Response;
}
Expand description
Types that can be converted into a Response
.
This trait is implemented for the following:
http::StatusCode
http::Response<impl Into<hyper::Body>>
String
&'static str
§Example
use warp::{Filter, http::Response};
struct Message {
msg: String
}
impl warp::Reply for Message {
fn into_response(self) -> warp::reply::Response {
Response::new(format!("message: {}", self.msg).into())
}
}
fn handler() -> Message {
Message { msg: "Hello".to_string() }
}
let route = warp::any().map(handler);
Required Methods§
sourcefn into_response(self) -> Response
fn into_response(self) -> Response
Converts the given value into a Response
.