pub trait Reply: BoxedReply + Send {
    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

Converts the given value into a Response.

Implementations on Foreign Types

Implementors