aboutsummaryrefslogtreecommitdiffstats
path: root/rust/fatcat-api/examples/server_lib/mod.rs
blob: a45fbe50f46d0f3d2ba2f4048a615cafdf1de1ac (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
//! Main library entry point for fatcat implementation.

mod server;

mod errors {
    error_chain!{}
}

pub use self::errors::*;
use fatcat;
use hyper;
use std::io;

pub struct NewService;

impl hyper::server::NewService for NewService {
    type Request = (hyper::Request, fatcat::Context);
    type Response = hyper::Response;
    type Error = hyper::Error;
    type Instance = fatcat::server::Service<server::Server>;

    /// Instantiate a new server.
    fn new_service(&self) -> io::Result<Self::Instance> {
        Ok(fatcat::server::Service::new(server::Server))
    }
}