Files
continuwuity/src/router/router.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
700 B
Rust
Raw Normal View History

2024-05-09 15:59:08 -07:00
use std::sync::Arc;
use axum::{response::IntoResponse, routing::get, Router};
use conduit::{Error, Server};
2024-06-05 07:30:30 +00:00
use conduit_service as service;
use http::{StatusCode, Uri};
2024-05-09 15:59:08 -07:00
use ruma::api::client::error::ErrorKind;
extern crate conduit_api as api;
pub(crate) fn build(server: &Arc<Server>) -> Router {
2024-06-05 07:30:30 +00:00
let state = service::services();
2024-07-14 23:46:03 +00:00
api::router::build(Router::new(), server)
2024-06-05 07:30:30 +00:00
.route("/", get(it_works))
.fallback(not_found)
.with_state(state);
2024-05-09 15:59:08 -07:00
2024-06-16 21:29:59 +00:00
api::routes::build(router, server)
2024-05-09 15:59:08 -07:00
}
async fn not_found(_uri: Uri) -> impl IntoResponse {
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!" }