You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-20 12:02:22 +03:00
Do not embed the templates and static files in the binary
This commit is contained in:
@@ -49,18 +49,18 @@ fn http_listener_spa_manifest_default() -> Utf8PathBuf {
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "docker"))]
|
||||
fn http_listener_spa_assets_default() -> Utf8PathBuf {
|
||||
fn http_listener_assets_path_default() -> Utf8PathBuf {
|
||||
"./frontend/dist/".into()
|
||||
}
|
||||
|
||||
#[cfg(feature = "docker")]
|
||||
fn http_listener_spa_manifest_default() -> Utf8PathBuf {
|
||||
"/usr/local/share/mas-cli/frontend-manifest.json".into()
|
||||
"/usr/local/share/mas-cli/manifest.json".into()
|
||||
}
|
||||
|
||||
#[cfg(feature = "docker")]
|
||||
fn http_listener_spa_assets_default() -> Utf8PathBuf {
|
||||
"/usr/local/share/mas-cli/frontend-assets/".into()
|
||||
fn http_listener_assets_path_default() -> Utf8PathBuf {
|
||||
"/usr/local/share/mas-cli/assets/".into()
|
||||
}
|
||||
|
||||
/// Kind of socket
|
||||
@@ -272,12 +272,11 @@ pub enum Resource {
|
||||
Compat,
|
||||
|
||||
/// Static files
|
||||
Static {
|
||||
/// Path from which to serve static files. If not specified, it will
|
||||
/// serve the static files embedded in the server binary
|
||||
#[serde(default)]
|
||||
#[schemars(with = "Option<String>")]
|
||||
web_root: Option<Utf8PathBuf>,
|
||||
Assets {
|
||||
/// Path to the directory to serve.
|
||||
#[serde(default = "http_listener_assets_path_default")]
|
||||
#[schemars(with = "String")]
|
||||
path: Utf8PathBuf,
|
||||
},
|
||||
|
||||
/// Mount a "/connection-info" handler which helps debugging informations on
|
||||
@@ -287,15 +286,10 @@ pub enum Resource {
|
||||
|
||||
/// Mount the single page app
|
||||
Spa {
|
||||
/// Path to the vite mamanifest.jsonnifest
|
||||
/// Path to the vite manifest.json
|
||||
#[serde(default = "http_listener_spa_manifest_default")]
|
||||
#[schemars(with = "String")]
|
||||
manifest: Utf8PathBuf,
|
||||
|
||||
/// Path to the assets to server
|
||||
#[serde(default = "http_listener_spa_assets_default")]
|
||||
#[schemars(with = "String")]
|
||||
assets: Utf8PathBuf,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -346,10 +340,11 @@ impl Default for HttpConfig {
|
||||
Resource::OAuth,
|
||||
Resource::Compat,
|
||||
Resource::GraphQL { playground: true },
|
||||
Resource::Static { web_root: None },
|
||||
Resource::Assets {
|
||||
path: http_listener_assets_path_default(),
|
||||
},
|
||||
Resource::Spa {
|
||||
manifest: http_listener_spa_manifest_default(),
|
||||
assets: http_listener_spa_assets_default(),
|
||||
},
|
||||
],
|
||||
tls: None,
|
||||
|
||||
@@ -20,28 +20,29 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::ConfigurationSection;
|
||||
|
||||
fn default_builtin() -> bool {
|
||||
true
|
||||
#[cfg(not(feature = "docker"))]
|
||||
fn default_path() -> Utf8PathBuf {
|
||||
"./templates/".into()
|
||||
}
|
||||
|
||||
#[cfg(feature = "docker")]
|
||||
fn default_path() -> Utf8PathBuf {
|
||||
"/usr/local/share/mas-cli/templates/".into()
|
||||
}
|
||||
|
||||
/// Configuration related to templates
|
||||
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)]
|
||||
pub struct TemplatesConfig {
|
||||
/// Path to the folder that holds the custom templates
|
||||
#[serde(default)]
|
||||
/// Path to the folder which holds the templates
|
||||
#[serde(default = "default_path")]
|
||||
#[schemars(with = "Option<String>")]
|
||||
pub path: Option<Utf8PathBuf>,
|
||||
|
||||
/// Load the templates embedded in the binary
|
||||
#[serde(default = "default_builtin")]
|
||||
pub builtin: bool,
|
||||
pub path: Utf8PathBuf,
|
||||
}
|
||||
|
||||
impl Default for TemplatesConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
path: None,
|
||||
builtin: default_builtin(),
|
||||
path: default_path(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user