summaryrefslogtreecommitdiff
path: root/src/server.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/server.rs b/src/server.rs
index a203af9..3d264a9 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -13,12 +13,12 @@ use rocket::request::FromRequest;
use rocket::request::Request;
use rocket::response::Redirect;
use rocket::State;
+use rocket_contrib::serve::StaticFiles;
use rocket_contrib::templates::Template;
use serde_json::map::Map;
use serde_json::to_value;
use serde_json::Value as Json;
use std::collections::HashMap;
-use rocket_contrib::serve::StaticFiles;
use crate::db;
use crate::error::Error;
@@ -78,17 +78,15 @@ fn profile(conn: Db, username: String) -> Result<Template, Error> {
context.insert("title".to_string(), json!(username));
let entries = db::get_entries(&*conn, &username)?;
- let headings =
- entries.first()
+ let headings = entries
+ .first()
.and_then(|e| e.payload.as_object())
.map(|e| e.keys().collect::<Vec<_>>());
context.insert("headings".to_string(), json!(headings));
context.insert(
"entries".to_string(),
- json!(entries
- .into_iter()
- .map(|e| e.payload)
- .collect::<Vec<_>>()));
+ json!(entries.into_iter().map(|e| e.payload).collect::<Vec<_>>()),
+ );
Ok(Template::render("profile", context))
}
@@ -196,8 +194,7 @@ fn link_strava(params: State<Params>) -> Redirect {
))
}
-pub fn start(conn: diesel::PgConnection, db_url: &str, base_url: &str,
- static_path: &str) {
+pub fn start(conn: diesel::PgConnection, db_url: &str, base_url: &str, static_path: &str) {
let mut database_config = HashMap::new();
let mut databases = HashMap::new();
database_config.insert("url", Value::from(db_url));
@@ -239,9 +236,7 @@ pub fn start(conn: diesel::PgConnection, db_url: &str, base_url: &str,
link_strava_callback
],
)
- .mount(
- "/static",
- StaticFiles::from(static_path))
+ .mount("/static", StaticFiles::from(static_path))
.attach(Template::fairing())
.attach(Db::fairing())
.launch();