aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/api_lib.rs
blob: cc8c2313bbd9ca3587bf1137125c827b1a6e1f7c (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
28
29
30
31
32
33
34
//! Main library entry point for fatcat implementation.

// Imports required by server library.
// extern crate fatcat;
// extern crate swagger;
extern crate futures;
extern crate chrono;
#[macro_use]
extern crate error_chain;

mod server;

mod errors {
    error_chain!{}
}

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

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))
    }
}