summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs51
1 files changed, 8 insertions, 43 deletions
diff --git a/src/lib.rs b/src/lib.rs
index d7f7b98..5f8118b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2,12 +2,9 @@
#![feature(decl_macro)]
#[macro_use]
extern crate rocket;
-use rocket::response;
-use rocket::State;
-use rocket_contrib::templates::Template;
-use std::collections::HashMap;
-mod strava;
+#[macro_use]
+extern crate diesel;
#[derive(Debug)]
pub struct Config {
@@ -16,41 +13,9 @@ pub struct Config {
pub base_url: String,
}
-#[get("/")]
-fn index() -> Template {
- let mut context = HashMap::new();
- context.insert("parent", "layout");
- context.insert("message", "Hello, World");
- Template::render("index", context)
-}
-
-#[get("/link_strava_callback?<code>")]
-fn link_strava_callback(config: State<Config>, code: String) -> String {
- strava::exchange_token(&config.client_id, &config.client_secret, &code);
- "OK".to_string()
-}
-
-#[get("/link_strava")]
-fn link_strava(config: State<Config>) -> response::Redirect {
- response::Redirect::to(
- format!(
- concat!(
- "https://www.strava.com/oauth/authorize?",
- "client_id={}&",
- "response_type=code&",
- "redirect_uri={}&",
- "approval_prompt=force&",
- "scope=read",
- ),
- config.client_id,
- format!("{}/link_strava_callback", config.base_url))
- )
-}
-
-pub fn start_server(config: Config) {
- rocket::ignite()
- .manage(config)
- .mount("/", routes![index, link_strava, link_strava_callback])
- .attach(Template::fairing())
- .launch();
-}
+pub mod error;
+pub mod db;
+pub mod models;
+mod schema;
+pub mod server;
+mod strava;