1use std::sync::Arc;
2
3use axum::{Router, response::IntoResponse, routing::get};
4use http::{StatusCode, Uri};
5use ruma::api::error::ErrorKind;
6use tuwunel_api::router::{state, state::Guard};
7use tuwunel_core::Error;
8use tuwunel_service::Services;
9
10pub(crate) fn build(services: &Arc<Services>) -> (Router, Guard) {
11 let router = Router::<state::State>::new();
12 let (state, guard) = state::create(services.clone());
13 let router = tuwunel_api::router::build(router, &services.server)
14 .route("/", get(it_works))
15 .fallback(not_found)
16 .with_state(state);
17
18 (router, guard)
19}
20
21async fn not_found(_uri: Uri) -> impl IntoResponse {
22 Error::Request(ErrorKind::Unrecognized, "Not Found".into(), StatusCode::NOT_FOUND)
23}
24
25async fn it_works() -> &'static str { "hewwo from tuwunel woof!" }