You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-07 17:03:01 +03:00
Use BoxedFilter on main handlers to reduce compile times
This avoids having opaque `impl Filter`, which moves the compile time in the `core` crate instead of the end `cli` one
This commit is contained in:
@@ -16,17 +16,16 @@ use hyper::header::CONTENT_TYPE;
|
||||
use mime::TEXT_PLAIN;
|
||||
use sqlx::{pool::PoolConnection, PgPool, Postgres};
|
||||
use tracing::{info_span, Instrument};
|
||||
use warp::{reply::with_header, Filter, Rejection, Reply};
|
||||
use warp::{filters::BoxedFilter, reply::with_header, Filter, Rejection, Reply};
|
||||
|
||||
use crate::{errors::WrapError, filters::database::connection};
|
||||
|
||||
pub fn filter(
|
||||
pool: &PgPool,
|
||||
) -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone + Send + Sync + 'static {
|
||||
pub fn filter(pool: &PgPool) -> BoxedFilter<(impl Reply,)> {
|
||||
warp::path!("health")
|
||||
.and(warp::get())
|
||||
.and(connection(pool))
|
||||
.and_then(get)
|
||||
.boxed()
|
||||
}
|
||||
|
||||
async fn get(mut conn: PoolConnection<Postgres>) -> Result<impl Reply, Rejection> {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
use mas_templates::Templates;
|
||||
use sqlx::PgPool;
|
||||
use warp::{Filter, Rejection, Reply};
|
||||
use warp::{filters::BoxedFilter, Filter, Reply};
|
||||
|
||||
use crate::config::RootConfig;
|
||||
|
||||
@@ -31,7 +31,7 @@ pub fn root(
|
||||
pool: &PgPool,
|
||||
templates: &Templates,
|
||||
config: &RootConfig,
|
||||
) -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone + Send + Sync + 'static {
|
||||
) -> BoxedFilter<(impl Reply,)> {
|
||||
health(pool)
|
||||
.or(oauth2(pool, templates, &config.oauth2, &config.cookies))
|
||||
.or(views(
|
||||
@@ -42,4 +42,5 @@ pub fn root(
|
||||
&config.cookies,
|
||||
))
|
||||
.with(warp::log(module_path!()))
|
||||
.boxed()
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
use mas_templates::Templates;
|
||||
use sqlx::PgPool;
|
||||
use warp::{Filter, Rejection, Reply};
|
||||
use warp::{filters::BoxedFilter, Filter, Reply};
|
||||
|
||||
use crate::config::{CookiesConfig, OAuth2Config};
|
||||
|
||||
@@ -37,7 +37,7 @@ pub fn filter(
|
||||
templates: &Templates,
|
||||
oauth2_config: &OAuth2Config,
|
||||
cookies_config: &CookiesConfig,
|
||||
) -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone + Send + Sync + 'static {
|
||||
) -> BoxedFilter<(impl Reply,)> {
|
||||
discovery(oauth2_config)
|
||||
.or(keys(oauth2_config))
|
||||
.or(authorization(
|
||||
@@ -49,4 +49,5 @@ pub fn filter(
|
||||
.or(userinfo(pool, oauth2_config))
|
||||
.or(introspection(pool, oauth2_config))
|
||||
.or(token(pool, oauth2_config))
|
||||
.boxed()
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
use mas_templates::Templates;
|
||||
use sqlx::PgPool;
|
||||
use warp::{Filter, Rejection, Reply};
|
||||
use warp::{filters::BoxedFilter, Filter, Reply};
|
||||
|
||||
use crate::config::{CookiesConfig, CsrfConfig, OAuth2Config};
|
||||
|
||||
@@ -37,7 +37,7 @@ pub(super) fn filter(
|
||||
oauth2_config: &OAuth2Config,
|
||||
csrf_config: &CsrfConfig,
|
||||
cookies_config: &CookiesConfig,
|
||||
) -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone + Send + Sync + 'static {
|
||||
) -> BoxedFilter<(impl Reply,)> {
|
||||
index(pool, templates, oauth2_config, csrf_config, cookies_config)
|
||||
.or(login(pool, templates, csrf_config, cookies_config))
|
||||
.or(register(pool, templates, csrf_config, cookies_config))
|
||||
|
Reference in New Issue
Block a user