add state to router

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-15 03:56:27 +00:00
parent 720fbd09c2
commit 038b71fc9d
4 changed files with 19 additions and 18 deletions

View file

@ -2,20 +2,19 @@ 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;
extern crate conduit_service as service;
pub(crate) fn build(server: &Arc<Server>) -> Router {
let state = service::services();
api::router::build(Router::new(), server)
let router = Router::<api::State>::new();
api::router::build(router, server)
.route("/", get(it_works))
.fallback(not_found)
.with_state(state);
api::routes::build(router, server)
.with_state(service::services())
}
async fn not_found(_uri: Uri) -> impl IntoResponse {