summaryrefslogtreecommitdiffstats
path: root/rust/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/lib.rs')
-rw-r--r--rust/src/lib.rs40
1 files changed, 34 insertions, 6 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index 679b9ed3..ec7193e6 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -1,18 +1,46 @@
-
#[macro_use]
+extern crate fatcat_api;
+extern crate chrono;
extern crate diesel;
extern crate dotenv;
+extern crate futures;
+extern crate hyper;
+extern crate swagger;
+#[macro_use]
+extern crate error_chain;
-use diesel::prelude::*;
+pub mod api_server;
+
+mod errors {
+ error_chain!{}
+}
+
+pub use self::errors::*;
use diesel::pg::PgConnection;
+use diesel::prelude::*;
use dotenv::dotenv;
use std::env;
+use std::io;
+//use hyper;
+//use fatcat_api;
pub fn establish_connection() -> PgConnection {
dotenv().ok();
- let database_url = env::var("DATABASE_URL")
- .expect("DATABASE_URL must be set");
- PgConnection::establish(&database_url)
- .expect(&format!("Error connecting to {}", database_url))
+ let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
+ PgConnection::establish(&database_url).expect(&format!("Error connecting to {}", database_url))
+}
+
+pub struct NewService;
+
+impl hyper::server::NewService for NewService {
+ type Request = (hyper::Request, fatcat_api::Context);
+ type Response = hyper::Response;
+ type Error = hyper::Error;
+ type Instance = fatcat_api::server::Service<api_server::Server>;
+
+ /// Instantiate a new server.
+ fn new_service(&self) -> io::Result<Self::Instance> {
+ Ok(fatcat_api::server::Service::new(api_server::Server))
+ }
}