diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/server.rs | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/examples/server.rs b/examples/server.rs index 7460f56..864c105 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -1,27 +1,26 @@ +extern crate conduit; extern crate http; +extern crate fastcgi_conduit; use std::fs::OpenOptions; use std::io::prelude::*; +use std::io; -use http::{Response, StatusCode}; +use conduit::{Body, RequestExt, Response}; +use conduit::header; -use fcgi; +use fastcgi_conduit::Server; fn main() { - 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(()) - .unwrap(); + Server::start(handler); +} - return resp; - }); +fn handler(req: &mut dyn RequestExt) -> io::Result<Response<Body>> { + Ok( + Response::builder() + .header(header::CONTENT_TYPE, "text/html") + .body(Body::from_static(b"<h1>Test</h1>")) + .unwrap() + ) } |