optimize api state extractor
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
ccef1a4c8b
commit
1f88866612
6 changed files with 81 additions and 23 deletions
|
@ -2,19 +2,20 @@ use std::sync::Arc;
|
|||
|
||||
use axum::{response::IntoResponse, routing::get, Router};
|
||||
use conduit::Error;
|
||||
use conduit_api::State;
|
||||
use conduit_api::router::{state, state::Guard};
|
||||
use conduit_service::Services;
|
||||
use http::{StatusCode, Uri};
|
||||
use ruma::api::client::error::ErrorKind;
|
||||
|
||||
pub(crate) fn build(services: &Arc<Services>) -> Router {
|
||||
let router = Router::<State>::new();
|
||||
let state = State::new(services.clone());
|
||||
|
||||
conduit_api::router::build(router, &services.server)
|
||||
pub(crate) fn build(services: &Arc<Services>) -> (Router, Guard) {
|
||||
let router = Router::<state::State>::new();
|
||||
let (state, guard) = state::create(services.clone());
|
||||
let router = conduit_api::router::build(router, &services.server)
|
||||
.route("/", get(it_works))
|
||||
.fallback(not_found)
|
||||
.with_state(state)
|
||||
.with_state(state);
|
||||
|
||||
(router, guard)
|
||||
}
|
||||
|
||||
async fn not_found(_uri: Uri) -> impl IntoResponse {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue