use simple styling
This commit is contained in:
parent
0f3fb34d85
commit
a94d23bc2c
6 changed files with 55 additions and 8 deletions
|
@ -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
12
src/css_handler.rs
Normal 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)
|
||||
}
|
|
@ -4,6 +4,7 @@ use crate::{config::PenguinConfig, feeds::enrich_feeds};
|
|||
|
||||
mod app;
|
||||
mod config;
|
||||
mod css_handler;
|
||||
mod feeds;
|
||||
mod hash;
|
||||
mod logging;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue