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

@ -522,3 +522,26 @@ impl Route for CompatLoginSsoComplete {
format!("/complete-compat-sso/{}", self.id).into()
}
}
/// `GET /assets`
pub struct StaticAsset {
path: String,
}
impl StaticAsset {
#[must_use]
pub fn new(path: String) -> Self {
Self { path }
}
}
impl Route for StaticAsset {
type Query = ();
fn route() -> &'static str {
"/assets"
}
fn path(&self) -> std::borrow::Cow<'static, str> {
format!("/assets/{}", self.path).into()
}
}

View File

@ -91,4 +91,10 @@ impl UrlBuilder {
pub fn jwks_uri(&self) -> Url {
self.url_for(&crate::endpoints::OAuth2Keys)
}
/// Static asset
#[must_use]
pub fn static_asset(&self, path: String) -> Url {
self.url_for(&crate::endpoints::StaticAsset::new(path))
}
}