aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/api_lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/api_lib.rs')
-rw-r--r--rust/src/api_lib.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/rust/src/api_lib.rs b/rust/src/api_lib.rs
new file mode 100644
index 00000000..cc8c2313
--- /dev/null
+++ b/rust/src/api_lib.rs
@@ -0,0 +1,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))
+ }
+}