Skip to content

Commit

Permalink
refactor: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
amitksingh1490 committed May 2, 2024
1 parent 6d743d9 commit 44d0465
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 14 additions & 10 deletions src/http/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
pub use cache::*;
pub use data_loader::*;
pub use data_loader_request::*;
use headers::HeaderValue;
pub use method::Method;
pub use request_context::RequestContext;
pub use request_handler::{handle_request, API_URL_PREFIX};
pub use request_template::RequestTemplate;
pub use response::*;

pub use crate::app_context::AppContext;

mod data_loader;

mod cache;
Expand All @@ -10,13 +22,5 @@ mod response;
pub mod showcase;
mod telemetry;

pub use cache::*;
pub use data_loader::*;
pub use data_loader_request::*;
pub use method::Method;
pub use request_context::RequestContext;
pub use request_handler::{handle_request, API_URL_PREFIX};
pub use request_template::RequestTemplate;
pub use response::*;

pub use crate::app_context::AppContext;
pub static TAILCALL_HTTPS_ORIGIN: HeaderValue = HeaderValue::from_static("https://tailcall.run");
pub static TAILCALL_HTTP_ORIGIN: HeaderValue = HeaderValue::from_static("http://tailcall.run");
4 changes: 2 additions & 2 deletions src/http/request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tracing_opentelemetry::OpenTelemetrySpanExt;

use super::request_context::RequestContext;
use super::telemetry::{get_response_status_code, RequestCounter};
use super::{showcase, telemetry, AppContext};
use super::{showcase, telemetry, AppContext, TAILCALL_HTTPS_ORIGIN, TAILCALL_HTTP_ORIGIN};
use crate::async_graphql_hyper::{GraphQLRequestLike, GraphQLResponse};
use crate::blueprint::telemetry::TelemetryExporter;
use crate::config::{PrometheusExporter, PrometheusFormat};
Expand Down Expand Up @@ -326,7 +326,7 @@ pub async fn handle_request<T: DeserializeOwned + GraphQLRequestLike>(
let response = if app_ctx.blueprint.server.cors.is_some() {
handle_request_with_cors::<T>(req, app_ctx, &mut req_counter).await
} else if let Some(origin) = req.headers().get(&header::ORIGIN) {
if origin == HeaderValue::from_static("https://tailcall.run") {
if origin == TAILCALL_HTTPS_ORIGIN || origin == TAILCALL_HTTP_ORIGIN {
handle_origin_tailcall::<T>(req, app_ctx, &mut req_counter).await
} else {
handle_request_inner::<T>(req, app_ctx, &mut req_counter).await
Expand Down

0 comments on commit 44d0465

Please sign in to comment.