From 23f23e7ee0540c1078db038c3b3cad93b312200a Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 23 Jun 2020 23:51:03 +0200 Subject: 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. --- examples/server.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'examples') 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(()) -- cgit v1.2.3