1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-31 09:24:31 +03:00

Mount the static assets on /assets

This commit is contained in:
Quentin Gliech
2022-09-30 15:31:47 +02:00
parent eeae943208
commit 93ce5c797c
8 changed files with 92 additions and 24 deletions

View File

@ -27,7 +27,7 @@ use mas_email::Mailer;
use mas_handlers::{AppState, MatrixHomeserver};
use mas_http::ServerLayer;
use mas_policy::PolicyFactory;
use mas_router::UrlBuilder;
use mas_router::{Route, UrlBuilder};
use mas_storage::MIGRATOR;
use mas_tasks::TaskQueue;
use mas_templates::Templates;
@ -201,10 +201,16 @@ impl Options {
.context("failed to load the policy")?;
let policy_factory = Arc::new(policy_factory);
let url_builder = UrlBuilder::new(config.http.public_base.clone());
// Load and compile the templates
let templates = Templates::load(config.templates.path.clone(), config.templates.builtin)
.await
.context("could not load templates")?;
let templates = Templates::load(
config.templates.path.clone(),
config.templates.builtin,
url_builder.clone(),
)
.await
.context("could not load templates")?;
let mailer = Mailer::new(
&templates,
@ -213,8 +219,6 @@ impl Options {
&config.email.reply_to,
);
let url_builder = UrlBuilder::new(config.http.public_base.clone());
let static_files = mas_static_files::service(&config.http.web_root);
let homeserver = MatrixHomeserver::new(config.matrix.homeserver.clone());
@ -246,7 +250,7 @@ impl Options {
};
let router = mas_handlers::router(state)
.fallback_service(static_files)
.nest(mas_router::StaticAsset::route(), static_files)
.layer(ServerLayer::default());
info!("Listening on http://{}", listener.local_addr().unwrap());

View File

@ -15,7 +15,6 @@
use std::path::PathBuf;
use clap::Parser;
use mas_config::TemplatesConfig;
use mas_templates::Templates;
#[derive(Parser, Debug)]
@ -58,11 +57,9 @@ impl Options {
}
SC::Check { path, skip_builtin } => {
let config = TemplatesConfig {
path: Some(path.to_string()),
builtin: !skip_builtin,
};
let templates = Templates::load(config.path.clone(), config.builtin).await?;
let url_builder = mas_router::UrlBuilder::new("https://example.com/".parse()?);
let templates =
Templates::load(Some(path.into()), !skip_builtin, url_builder).await?;
templates.check_render().await?;
Ok(())