Forgot to add matrix routes >:(
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
Jef Roosens 2022-04-02 14:16:35 +02:00
parent 799d0d4711
commit 322f0430bf
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
3 changed files with 16 additions and 3 deletions

View file

@ -1,12 +1,13 @@
use axum::{
extract::{BodyStream, Extension},
http::StatusCode,
response::IntoResponse,
routing::{get_service, post},
response::{IntoResponse, Json},
routing::{get, get_service, post},
Router,
};
use flate2::read::GzDecoder;
use futures_util::TryStreamExt;
use serde_json::{json, Value};
use std::collections::HashSet;
use std::io::ErrorKind;
use std::net::SocketAddr;
@ -37,6 +38,8 @@ async fn main() {
std::fs::create_dir_all(&static_dir);
let app = Router::new()
.route("/.well-known/matrix/server", get(get_matrix_server))
.route("/.well-known/matrix/client", get(get_matrix_client))
.route(
"/api/deploy",
post(post_deploy).layer(RequireAuthorizationLayer::bearer(&api_key)),
@ -61,6 +64,14 @@ async fn main() {
.unwrap();
}
async fn get_matrix_server() -> impl IntoResponse {
Json(json!({"m.server": "matrix.rustybever.be:443"}))
}
async fn get_matrix_client() -> impl IntoResponse {
Json(json!({"m.homeserver": {"base_url": "https://matrix.rustybever.be"}}))
}
async fn post_deploy(Extension(data_dir): Extension<String>, res: BodyStream) -> impl IntoResponse {
// This converts a stream into something that implements AsyncRead, which we can then use to
// asynchronously write the file to disk