1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-27 22:41:13 +03:00

Refactor listeners building

This commit is contained in:
Quentin Gliech
2022-10-05 13:19:02 +02:00
parent 014a8366ed
commit c548417752
10 changed files with 245 additions and 157 deletions

View File

@@ -155,14 +155,11 @@ use tower_http::services::ServeDir;
pub fn service<B: HttpBody + Send + 'static>(
path: &Option<PathBuf>,
) -> BoxCloneService<Request<B>, Response, Infallible> {
let builtin = self::builtin::service();
let svc = if let Some(path) = path {
let handler = ServeDir::new(path)
.append_index_html_on_directories(false)
.fallback(builtin);
let handler = ServeDir::new(path).append_index_html_on_directories(false);
on_service(MethodFilter::HEAD | MethodFilter::GET, handler)
} else {
let builtin = self::builtin::service();
on_service(MethodFilter::HEAD | MethodFilter::GET, builtin)
};