use simple styling

This commit is contained in:
Sebastian Hugentobler 2023-11-18 09:50:50 +01:00
parent 0f3fb34d85
commit a94d23bc2c
Signed by: shu
GPG key ID: BB32CF3CA052C2F0
6 changed files with 55 additions and 8 deletions

View file

@ -1,10 +1,10 @@
use std::collections::HashMap;
use std::sync::Arc;
use axum::Router;
use axum::{routing::get, Router};
use tower_http::trace::TraceLayer;
use crate::{feeds::Feed, routes};
use crate::{css_handler::stylesheet_handler, feeds::Feed, routes};
#[derive(Debug)]
pub struct AppState {
@ -15,6 +15,7 @@ pub fn create(feeds: HashMap<String, Feed>) -> Router {
let app_state = Arc::new(AppState { feeds });
Router::new()
.route("/styles.css", get(stylesheet_handler))
.nest("/", routes::all())
.with_state(app_state)
.layer(TraceLayer::new_for_http())

12
src/css_handler.rs Normal file
View file

@ -0,0 +1,12 @@
use axum::http::StatusCode;
use axum::{http::Response, response::IntoResponse};
static STYLESHEET: &str = include_str!("../static/styles.css");
pub async fn stylesheet_handler() -> Result<impl IntoResponse, StatusCode> {
let response = Response::builder()
.header("Content-Type", "text/css")
.body(STYLESHEET.to_string());
response.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
}

View file

@ -4,6 +4,7 @@ use crate::{config::PenguinConfig, feeds::enrich_feeds};
mod app;
mod config;
mod css_handler;
mod feeds;
mod hash;
mod logging;