feat: Prefill server name in federation test
This commit is contained in:
parent
cbcf4300df
commit
fb9d4c30f4
9 changed files with 24 additions and 12 deletions
|
@ -1,23 +1,34 @@
|
|||
use askama::Template;
|
||||
use axum::{
|
||||
Router,
|
||||
extract::State,
|
||||
http::{StatusCode, header},
|
||||
response::{Html, IntoResponse, Response},
|
||||
routing::get,
|
||||
};
|
||||
use conduwuit_build_metadata::{GIT_REMOTE_COMMIT_URL, GIT_REMOTE_WEB_URL, VERSION_EXTRA};
|
||||
use conduwuit_service::state;
|
||||
|
||||
pub fn build<S>() -> Router<()> { Router::new().route("/", get(index_handler)) }
|
||||
pub fn build() -> Router<state::State> {
|
||||
let router = Router::<state::State>::new();
|
||||
router.route("/", get(index_handler))
|
||||
}
|
||||
|
||||
async fn index_handler() -> Result<impl IntoResponse, WebError> {
|
||||
async fn index_handler(
|
||||
State(services): State<state::State>,
|
||||
) -> Result<impl IntoResponse, WebError> {
|
||||
#[derive(Debug, Template)]
|
||||
#[template(path = "index.html.j2")]
|
||||
struct Tmpl<'a> {
|
||||
nonce: &'a str,
|
||||
server_name: &'a str,
|
||||
}
|
||||
let nonce = rand::random::<u64>().to_string();
|
||||
|
||||
let template = Tmpl { nonce: &nonce };
|
||||
let template = Tmpl {
|
||||
nonce: &nonce,
|
||||
server_name: services.config.server_name.as_str(),
|
||||
};
|
||||
Ok((
|
||||
[(header::CONTENT_SECURITY_POLICY, format!("default-src 'none' 'nonce-{nonce}';"))],
|
||||
Html(template.render()?),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue