finchers
finchers copied to clipboard
Introduce ResponderExt
trait ResponderExt: Responder {
fn status(self, status: StatusCode) -> Status<Self>;
fn content_type<S: AsRef<str>>(self, content_type: S) -> ContentType<Self, S>;
}
impl<T: Responder> ResponderExt for T {}
Usage
path("posts").and(path::param()).and(body::parse())
.map(|id: u32, body: String| {
format!("{{ \"id\":{}, \"body\":\"{}\" }}", id, escaped(body))
.status(StatusCode::CREATED)
.content_type("application/json")
})