continuwuity/src/router/router.rs
2026-03-18 12:42:55 -04:00

22 lines
691 B
Rust

use std::sync::Arc;
use axum::{Router, response::IntoResponse};
use conduwuit::Error;
use conduwuit_service::{Services, state, state::Guard};
use http::{StatusCode, Uri};
use ruma::api::client::error::ErrorKind;
pub(crate) fn build(services: &Arc<Services>) -> (Router, Guard) {
let router = Router::<state::State>::new();
let (state, guard) = state::create(services.clone());
let router = conduwuit_api::router::build(router, &services.server)
.merge(conduwuit_web::build())
.fallback(not_found)
.with_state(state);
(router, guard)
}
async fn not_found(_uri: Uri) -> impl IntoResponse {
Error::Request(ErrorKind::Unrecognized, "not found :(".into(), StatusCode::NOT_FOUND)
}