continuwuity/src/router/router.rs
Jason Volk c2267d4c03 add services state to router
Signed-off-by: Jason Volk <jason@zemos.net>
2024-06-07 02:00:28 +00:00

25 lines
655 B
Rust

use std::sync::Arc;
use axum::{response::IntoResponse, routing::get, Router};
use conduit::{Error, Server};
use conduit_service as service;
use http::Uri;
use ruma::api::client::error::ErrorKind;
extern crate conduit_api as api;
pub(crate) fn build(server: &Arc<Server>) -> Router {
let state = service::services();
let router = Router::new()
.route("/", get(it_works))
.fallback(not_found)
.with_state(state);
api::router::build(router, server)
}
async fn not_found(_uri: Uri) -> impl IntoResponse {
Error::BadRequest(ErrorKind::Unrecognized, "Unrecognized request")
}
async fn it_works() -> &'static str { "hewwo from conduwuit woof!" }