1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-20 12:02:22 +03:00

Add a global HTTP client factory

This commit is contained in:
Quentin Gliech
2022-11-23 13:18:48 +01:00
parent d514a8922c
commit 4227fa7a83
14 changed files with 163 additions and 83 deletions

View File

@@ -18,6 +18,7 @@ use axum::{
};
use axum_extra::extract::{cookie::Cookie, PrivateCookieJar};
use hyper::StatusCode;
use mas_axum_utils::http_client_factory::HttpClientFactory;
use mas_http::ClientInitError;
use mas_keystore::Encrypter;
use mas_oidc_client::{
@@ -30,8 +31,6 @@ use sqlx::PgPool;
use thiserror::Error;
use ulid::Ulid;
use super::http_service;
#[derive(Debug, Error)]
pub(crate) enum RouteError {
#[error("Provider not found")]
@@ -89,6 +88,7 @@ impl IntoResponse for RouteError {
}
pub(crate) async fn get(
State(http_client_factory): State<HttpClientFactory>,
State(pool): State<PgPool>,
State(url_builder): State<UrlBuilder>,
cookie_jar: PrivateCookieJar<Encrypter>,
@@ -103,7 +103,9 @@ pub(crate) async fn get(
.to_option()?
.ok_or(RouteError::ProviderNotFound)?;
let http_service = http_service("upstream-discover").await?;
let http_service = http_client_factory
.http_service("upstream-discover")
.await?;
// First, discover the provider
let metadata =