diff --git a/src/main.rs b/src/main.rs index d376aea..0625ee9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,6 @@ use warp::{ Filter, Buf, reply::Response, - http, }; use hyper::Body; use std::{ @@ -30,6 +29,12 @@ use tokio::{ }; use cfg_if::cfg_if; +macro_rules! status { + ($code:expr) => { + ::warp::http::status::StatusCode::from_u16($code).unwrap() + }; +} + #[cfg(feature="trust-x-forwarded-for")] mod forwarded_list; #[cfg(feature="trust-x-forwarded-for")] @@ -131,14 +136,10 @@ async fn main() { .and_then(|chain: Arc>>, host: IpAddr, buf| { async move { full_body(&host, chain, buf).await - .map(|x| format!("{} bytes fed", x)) + .map(|_| warp::reply::with_status(warp::reply(), status!(201))) .map_err(warp::reject::custom) } }) - .map(|x| http::Response::builder() - .status(201) - .body(x) - .unwrap()) .with(warp::log("markov::put")); let read = warp::get()