You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-31 09:24:31 +03:00
Migrate to axum 0.6.0-rc.5
This commit is contained in:
@ -29,6 +29,7 @@ use mas_storage::MIGRATOR;
|
||||
use mas_tasks::TaskQueue;
|
||||
use mas_templates::Templates;
|
||||
use tokio::signal::unix::SignalKind;
|
||||
use tower::Layer;
|
||||
use tracing::{error, info, log::warn};
|
||||
|
||||
#[derive(Parser, Debug, Default)]
|
||||
@ -215,9 +216,8 @@ impl Options {
|
||||
};
|
||||
|
||||
// and build the router
|
||||
let router = crate::server::build_router(state.clone(), &config.resources)
|
||||
.layer(ServerLayer::new(config.name.clone()))
|
||||
.into_service();
|
||||
let router = crate::server::build_router(state.clone(), &config.resources);
|
||||
let router = ServerLayer::new(config.name.clone()).layer(router);
|
||||
|
||||
// Display some informations about where we'll be serving connections
|
||||
let is_tls = config.tls.is_some();
|
||||
|
@ -19,7 +19,10 @@ use std::{
|
||||
};
|
||||
|
||||
use anyhow::Context;
|
||||
use axum::{body::HttpBody, error_handling::HandleErrorLayer, extract::FromRef, Extension, Router};
|
||||
use axum::{
|
||||
body::HttpBody, error_handling::HandleErrorLayer, extract::FromRef, Extension, Router,
|
||||
RouterService,
|
||||
};
|
||||
use hyper::StatusCode;
|
||||
use listenfd::ListenFd;
|
||||
use mas_config::{HttpBindConfig, HttpResource, HttpTlsConfig, UnixOrTcp};
|
||||
@ -33,14 +36,14 @@ use tower::Layer;
|
||||
use tower_http::services::ServeDir;
|
||||
|
||||
#[allow(clippy::trait_duplication_in_bounds)]
|
||||
pub fn build_router<B>(state: AppState, resources: &[HttpResource]) -> Router<AppState, B>
|
||||
pub fn build_router<B>(state: AppState, resources: &[HttpResource]) -> RouterService<B>
|
||||
where
|
||||
B: HttpBody + Send + 'static,
|
||||
<B as HttpBody>::Data: Into<axum::body::Bytes> + Send,
|
||||
<B as HttpBody>::Error: std::error::Error + Send + Sync,
|
||||
{
|
||||
let templates = Templates::from_ref(&state);
|
||||
let mut router = Router::with_state(state);
|
||||
let mut router = Router::new();
|
||||
|
||||
for resource in resources {
|
||||
router = match resource {
|
||||
@ -106,7 +109,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
router
|
||||
router.with_state(state)
|
||||
}
|
||||
|
||||
pub fn build_tls_server_config(config: &HttpTlsConfig) -> Result<ServerConfig, anyhow::Error> {
|
||||
|
Reference in New Issue
Block a user