Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions apollo-router/src/axum_factory/axum_http_server_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use crate::http_server_factory::Listener;
use crate::plugins::telemetry::formatters::TRACE_ID_FIELD_NAME;
use crate::router::ApolloRouterError;
use crate::router_factory::Endpoint;
use crate::router_factory::SupergraphServiceFactory;
use crate::router_factory::TransportServiceFactory;
use crate::services::layers::apq::APQLayer;
use crate::services::transport;
use crate::tracer::TraceId;
Expand Down Expand Up @@ -95,7 +95,7 @@ pub(crate) fn make_axum_router<RF>(
apq: APQLayer,
) -> Result<ListenersAndRouters, ApolloRouterError>
where
RF: SupergraphServiceFactory,
RF: TransportServiceFactory,
{
ensure_listenaddrs_consistency(configuration, &endpoints)?;

Expand All @@ -115,7 +115,8 @@ where

async move {
Ok(http::Response::builder()
.body(serde_json::to_vec(&health).map_err(BoxError::from)?.into())?)
.body(serde_json::to_vec(&health).map_err(BoxError::from)?.into())?
.into())
}
})
.boxed(),
Expand Down Expand Up @@ -160,7 +161,7 @@ impl HttpServerFactory for AxumHttpServerFactory {
extra_endpoints: MultiMap<ListenAddr, Endpoint>,
) -> Self::Future
where
RF: SupergraphServiceFactory,
RF: TransportServiceFactory,
{
Box::pin(async move {
let apq = APQLayer::with_cache(DeduplicatingCache::new().await);
Expand Down Expand Up @@ -292,15 +293,17 @@ fn main_endpoint<RF>(
apq: APQLayer,
) -> Result<ListenAddrAndRouter, ApolloRouterError>
where
RF: SupergraphServiceFactory,
RF: TransportServiceFactory,
{
let cors = configuration.cors.clone().into_layer().map_err(|e| {
ApolloRouterError::ServiceCreationError(format!("CORS configuration error: {e}").into())
})?;

let main_route = main_router::<RF>(configuration, apq)
// .layer(my_http_service_stack_except_its_layered_now)
.layer(middleware::from_fn(decompress_request_body))
.layer(
// TODO: move it to the telemetry plugin.
TraceLayer::new_for_http()
.make_span_with(PropagatingMakeSpan::new())
.on_request(|_: &Request<_>, span: &Span| {
Expand Down Expand Up @@ -344,7 +347,7 @@ where

pub(super) fn main_router<RF>(configuration: &Configuration, apq: APQLayer) -> axum::Router
where
RF: SupergraphServiceFactory,
RF: TransportServiceFactory,
{
let mut graphql_configuration = configuration.supergraph.clone();
if graphql_configuration.path.ends_with("/*") {
Expand Down Expand Up @@ -391,14 +394,14 @@ where
.post({
move |host: Host,
uri: OriginalUri,
request: Json<graphql::Request>,
http_request: Request<Body>,
Extension(service): Extension<RF>,
header_map: HeaderMap| {
{
handle_post(
host,
uri,
request,
http_request,
apq,
service.new_service().boxed(),
header_map,
Expand Down
Loading