Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt at deploying on shuttle.rs #2

Closed
wants to merge 16 commits into from
16 changes: 10 additions & 6 deletions src/lib.rs
Expand Up @@ -23,12 +23,12 @@ mod model;
use crate::{
config::Config,
controllers::{bands, callers, cities, index, organisations, reload},
errors::internal_error,
importers::{balfolknl, folkbalbende, webfeet},
model::events::Events,
};
use axum::{
routing::{get, get_service, post},
http::header,
routing::{get, post},
Extension, Router,
};
use eyre::Report;
Expand Down Expand Up @@ -107,10 +107,14 @@ pub async fn setup_app(config: &Config) -> Result<Router, Report> {
.route("/cities", get(cities::cities))
.route("/organisations", get(organisations::organisations))
.route("/reload", post(reload::reload))
.nest(
"/stylesheets",
get_service(ServeDir::new(config.public_dir.join("stylesheets")))
.handle_error(internal_error),
.route(
"/stylesheets/main.css",
get(|| async {
(
[(header::CONTENT_TYPE, "text/css")],
include_str!("../public/stylesheets/main.css"),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discussed this with Andrew - edit-compile-serve iteration times on axum are pretty slow, so his previous get_service(ServeDir::new(config.public_dir.join("stylesheets"))) approach is super valuable if you want to iterate quickly on your CSS.

)
}),
)
.layer(Extension(events));

Expand Down