//! HTTP route handlers
use crate::config::AppConfig;
use crate::files::{
FIXI_JS, FIXI_SKILL, MOXI_SKILL, PAXI_SKILL, REXI_SKILL, SSEXI_SKILL, TACHYONS_CSS,
};
use crate::views::index_page;
use actix_web::{HttpResponse, Responder, get, web};
/// Serve tachyons CSS
#[get("/up")]
pub async fn up() -> impl Responder {
HttpResponse::Ok()
}
/// Serve the main index page
#[get("/")]
pub async fn index(config: web::Data<AppConfig>) -> impl Responder {
let base_url = config.base_url();
HttpResponse::Ok()
.content_type("text/html")
.body(index_page(&base_url).into_string())
}
/// Serve tachyons CSS
#[get("/tachyons.css")]
pub async fn serve_tachyons() -> impl Responder {
HttpResponse::Ok()
.content_type("text/css")
.body(TACHYONS_CSS)
}
/// Serve fixi JavaScript bundle
#[get("/the-fixi-project@0.1.1.min.js")]
pub async fn serve_fixi_js() -> impl Responder {
HttpResponse::Ok()
.content_type("application/javascript")
.body(FIXI_JS)
}
/// Serve fixi skill markdown
#[get("/fixi.md")]
pub async fn serve_fixi_skill() -> impl Responder {
HttpResponse::Ok()
.content_type("text/markdown")
.body(FIXI_SKILL)
}
/// Serve moxi skill markdown
#[get("/moxi.md")]
pub async fn serve_moxi_skill() -> impl Responder {
HttpResponse::Ok()
.content_type("text/markdown")
.body(MOXI_SKILL)
}
/// Serve paxi skill markdown
#[get("/paxi.md")]
pub async fn serve_paxi_skill() -> impl Responder {
HttpResponse::Ok()
.content_type("text/markdown")
.body(PAXI_SKILL)
}
/// Serve ssexi skill markdown
#[get("/ssexi.md")]
pub async fn serve_ssexi_skill() -> impl Responder {
HttpResponse::Ok()
.content_type("text/markdown")
.body(SSEXI_SKILL)
}
/// Serve rexi skill markdown
#[get("/rexi.md")]
pub async fn serve_rexi_skill() -> impl Responder {
HttpResponse::Ok()
.content_type("text/markdown")
.body(REXI_SKILL)
}