2024-05-09 15:59:08 -07:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
use axum::{response::IntoResponse, routing::get, Router};
|
2024-07-27 07:17:07 +00:00
|
|
|
use conduit::Error;
|
|
|
|
use conduit_api::State;
|
|
|
|
use conduit_service::Services;
|
2024-07-15 01:49:30 +00:00
|
|
|
use http::{StatusCode, Uri};
|
2024-05-09 15:59:08 -07:00
|
|
|
use ruma::api::client::error::ErrorKind;
|
|
|
|
|
2024-07-27 07:17:07 +00:00
|
|
|
pub(crate) fn build(services: &Arc<Services>) -> Router {
|
|
|
|
let router = Router::<State>::new();
|
2024-07-28 21:31:35 +00:00
|
|
|
let state = State::new(services.clone());
|
2024-05-09 15:59:08 -07:00
|
|
|
|
2024-07-27 07:17:07 +00:00
|
|
|
conduit_api::router::build(router, &services.server)
|
2024-06-05 07:30:30 +00:00
|
|
|
.route("/", get(it_works))
|
|
|
|
.fallback(not_found)
|
2024-07-27 07:17:07 +00:00
|
|
|
.with_state(state)
|
2024-05-09 15:59:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
async fn not_found(_uri: Uri) -> impl IntoResponse {
|
2024-07-15 01:49:30 +00:00
|
|
|
Error::Request(ErrorKind::Unrecognized, "Not Found".into(), StatusCode::NOT_FOUND)
|
2024-05-09 15:59:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
async fn it_works() -> &'static str { "hewwo from conduwuit woof!" }
|