aboutsummaryrefslogtreecommitdiffstats
path: root/examples/server.rs
blob: 464e56422fd6e82be640f362bd3553f60c251b5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
extern crate conduit;
extern crate http;
extern crate fastcgi_conduit;

use std::fs::OpenOptions;
use std::io::prelude::*;
use std::io;

use conduit::{Body, RequestExt, Response};
use conduit::header;

use fastcgi_conduit::Server;


fn main() {
    Server::start(handler);
}

fn handler(req: &mut dyn RequestExt) -> io::Result<Response<Body>> {
    Ok(
        Response::builder()
            .status(202)
            .header(header::CONTENT_TYPE, "text/html")
            .body(Body::from_static(b"<h1>Test</h1>"))
            .unwrap()
    )
}