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 /examples/server.rs | |
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 'examples/server.rs')
-rw-r--r-- | examples/server.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/server.rs b/examples/server.rs index 861984c..7460f56 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -1,12 +1,22 @@ extern crate http; +use std::fs::OpenOptions; +use std::io::prelude::*; + use http::{Response, StatusCode}; use fcgi; fn main() { - fcgi::run(|req| { + fcgi::run(move |req| { + let mut file = OpenOptions::new() + .write(true) + .append(true) + .open("/tmp/fcgi-log.txt") + .unwrap(); + write!(file, "ยป {:?}\n", req).unwrap(); + let resp = Response::builder() .status(StatusCode::OK) .body(()) |