diff options
author | Teddy Wing | 2020-06-23 23:51:03 +0200 |
---|---|---|
committer | Teddy Wing | 2020-06-23 23:51:03 +0200 |
commit | 23f23e7ee0540c1078db038c3b3cad93b312200a (patch) | |
tree | e31fd3eb23ec5b8ef5922158b609b5968282d8cd /src | |
parent | d005c2017cfc5150ab6890d610cc097780e495ce (diff) | |
download | fastcgi-conduit-23f23e7ee0540c1078db038c3b3cad93b312200a.tar.bz2 |
run(): Convert `fastcgi::Request` to `http::Request`
Build a new `http::Request` from the `fastcgi::Request` and pass it into
the closure.
Can't move `req`, so needed to change the `from` converter to take a
reference.
Update the example code to append the `http::Request` to a file for
debugging and inspection.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -12,13 +12,9 @@ pub fn run<F, T>(handler: F) where F: Fn(Request<()>) -> Response<T> + Send + Sync + 'static { fastcgi::run(move |mut req| { - // build request - let r = request::Builder::new() - .method("GET") - .body(()) - .unwrap(); + let r: http::request::Builder = From::from(&req); - handler(r); + handler(r.body(()).unwrap()); let params = req.params() .map(|(k, v)| k + ": " + &v) @@ -38,8 +34,8 @@ trait From<T>: Sized { fn from(_: T) -> Self; } -impl From<fastcgi::Request> for http::request::Builder { - fn from(request: fastcgi::Request) -> Self { +impl From<&fastcgi::Request> for http::request::Builder { + fn from(request: &fastcgi::Request) -> Self { let method = request.param("REQUEST_METHOD") .unwrap_or("".to_owned()); |