continuwuity/src/router/router.rs
Jason Volk 720fbd09c2 move routes into api router top level
Signed-off-by: Jason Volk <jason@zemos.net>
2024-07-16 02:39:49 +00:00

25 lines
700 B
Rust

use std::sync::Arc;
use axum::{response::IntoResponse, routing::get, Router};
use conduit::{Error, Server};
use conduit_service as service;
use http::{StatusCode, 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();
api::router::build(Router::new(), server)
.route("/", get(it_works))
.fallback(not_found)
.with_state(state);
api::routes::build(router, server)
}
async fn not_found(_uri: Uri) -> impl IntoResponse {
Error::Request(ErrorKind::Unrecognized, "Not Found".into(), StatusCode::NOT_FOUND)
}
async fn it_works() -> &'static str { "hewwo from conduwuit woof!" }