diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-14 23:17:26 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-14 23:17:26 -0700 |
commit | 2c56f2b65bcf3b3f85db9d2a34501154c9c9404d (patch) | |
tree | d9580fb8578f6e1ea0f47dd1e6402ebd41d3a0e9 /rust/src/lib.rs | |
parent | e468707ee53f4a8ff75b00a1eec44921672464b6 (diff) | |
download | fatcat-2c56f2b65bcf3b3f85db9d2a34501154c9c9404d.tar.gz fatcat-2c56f2b65bcf3b3f85db9d2a34501154c9c9404d.zip |
regenerated and pseudo-integrated
Diffstat (limited to 'rust/src/lib.rs')
-rw-r--r-- | rust/src/lib.rs | 40 |
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)) + } } |