aboutsummaryrefslogblamecommitdiffstats
path: root/src/main.rs
blob: 65a40c46beb2918978b74179ca96330e8e61eec3 (plain) (tree)













































                                                                                           
use rocket::fs::{relative, FileServer};
use rocket::{response::Responder, serde::json::Json};
use rocket_dyn_templates::{context, Template};

#[macro_use]
extern crate rocket;

#[get("/")]
async fn home() -> Template {
    Template::render("home", context! { is_live: true, is_scrobbling: true })
}

#[get("/contact")]
async fn contact() -> Template {
    Template::render("contact", context! {})
}

// #[get("/test")]
// async fn test() -> Result<Template, BlossomError> {
//     let posts = reqwest::get("https://skinnyver.se/api/v1/accounts/cel/statuses").await;
//     posts
// }

#[tokio::main]
async fn main() -> Result<(), rocket::Error> {
    let _rocket = rocket::build()
        .attach(Template::fairing())
        .mount("/", routes![home, contact])
        .mount("/", FileServer::from(relative!("static")))
        .launch()
        .await?;

    Ok(())
}

#[derive(Responder)]
enum BlossomError {
    #[response(status = 500)]
    Reqwest(&'static str, #[response(ignore)] reqwest::Error),
}

impl From<reqwest::Error> for BlossomError {
    fn from(e: reqwest::Error) -> Self {
        BlossomError::Reqwest("reqwest error", e)
    }
}