aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/lib.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-15 14:48:41 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-15 14:48:41 -0700
commite35b10434aa4ceb2708610f13fe078e977496ce5 (patch)
treecb4983cf8a6b64a6d512ce9f3e9c968cce2e5a2b /rust/src/lib.rs
parentfe77445bd16db003e03b5c44fa02c65b78e6fa02 (diff)
downloadfatcat-e35b10434aa4ceb2708610f13fe078e977496ce5.tar.gz
fatcat-e35b10434aa4ceb2708610f13fe078e977496ce5.zip
fmt
Diffstat (limited to 'rust/src/lib.rs')
-rw-r--r--rust/src/lib.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index c1336561..b8f2be88 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -1,19 +1,22 @@
#[macro_use]
extern crate fatcat_api;
extern crate chrono;
-#[macro_use] extern crate diesel;
-extern crate iron_diesel_middleware;
+#[macro_use]
+extern crate diesel;
extern crate dotenv;
extern crate futures;
-#[macro_use] extern crate hyper;
+extern crate iron_diesel_middleware;
+#[macro_use]
+extern crate hyper;
extern crate swagger;
-#[macro_use] extern crate error_chain;
+#[macro_use]
+extern crate error_chain;
extern crate iron;
extern crate r2d2;
extern crate r2d2_diesel;
-pub mod database_schema;
pub mod api_server;
+pub mod database_schema;
mod errors {
error_chain!{}
@@ -23,10 +26,10 @@ pub use self::errors::*;
use diesel::pg::PgConnection;
use diesel::prelude::*;
use dotenv::dotenv;
-use std::env;
-use iron::{Request, Response};
use iron::middleware::AfterMiddleware;
+use iron::{Request, Response};
use r2d2_diesel::ConnectionManager;
+use std::env;
pub type ConnectionPool = r2d2::Pool<r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>>;
@@ -42,10 +45,10 @@ pub fn server() -> Result<api_server::Server> {
dotenv().ok();
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let manager = ConnectionManager::<PgConnection>::new(database_url);
- let pool = r2d2::Pool::builder().build(manager).expect("Failed to create database pool.");
- Ok(api_server::Server {
- db_pool: pool,
- })
+ let pool = r2d2::Pool::builder()
+ .build(manager)
+ .expect("Failed to create database pool.");
+ Ok(api_server::Server { db_pool: pool })
}
/// HTTP header middleware
@@ -55,7 +58,8 @@ pub struct XClacksOverheadMiddleware;
impl AfterMiddleware for XClacksOverheadMiddleware {
fn after(&self, _req: &mut Request, mut res: Response) -> iron::IronResult<Response> {
- res.headers.set(XClacksOverhead("GNU aaronsw, jpb".to_owned()));
+ res.headers
+ .set(XClacksOverhead("GNU aaronsw, jpb".to_owned()));
Ok(res)
}
}