Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: enhance request_handler #1687

Closed
wants to merge 1 commit into from
Closed
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
37 changes: 16 additions & 21 deletions src/http/request_handler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::borrow::Cow;
use std::collections::BTreeSet;
use std::ops::Deref;

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Check Examples

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-gnu

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

unused import: `std::ops::Deref`

Check warning on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-arm64-msvc

unused import: `std::ops::Deref`

Check failure on line 3 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-gnu

unused import: `std::ops::Deref`
use std::sync::Arc;

use anyhow::Result;
Expand Down Expand Up @@ -71,13 +71,15 @@
.body(Body::empty())?)
}

fn create_request_context(req: &Request<Body>, app_ctx: &AppContext) -> RequestContext {
fn create_request_context<'a>(
req: &Request<Body>,
app_ctx: &'a AppContext,
)-> RequestContext <'a> {
let upstream = app_ctx.blueprint.upstream.clone();
let allowed = upstream.allowed_headers;
let allowed_headers = create_allowed_headers(req.headers(), &allowed);

let _allowed = app_ctx.blueprint.server.get_experimental_headers();
RequestContext::from(app_ctx).allowed_headers(allowed_headers)
request_context::from(app_ctx).allowed_headers(allowed_headers)
}

fn update_cache_control_header(
Expand All @@ -94,40 +96,37 @@
}

pub fn update_response_headers(
resp: &mut hyper::Response<hyper::Body>,
req_ctx: &RequestContext,
app_ctx: &AppContext,
resp = &mut Response<Body>

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Check Examples

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-gnu

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

expected one of `:`, `@`, or `|`, found `=`

Check warning on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

consider choosing a more descriptive name

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-arm64-msvc

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 99 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-gnu

expected one of `:`, `@`, or `|`, found `=`
req_ctx = &RequestContext,
app_ctx = &AppContext,

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Check Examples

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-gnu

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-arm64-msvc

expected one of `:`, `@`, or `|`, found `=`

Check failure on line 101 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-gnu

expected one of `:`, `@`, or `|`, found `=`
) {
if !app_ctx.blueprint.server.response_headers.is_empty() {

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Check Examples

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-gnu

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-arm64-msvc

cannot find value `app_ctx` in this scope

Check failure on line 103 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-gnu

cannot find value `app_ctx` in this scope
// Add static response headers
resp.headers_mut()

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Check Examples

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-gnu

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-arm64-msvc

cannot find value `resp` in this scope

Check failure on line 104 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-gnu

cannot find value `resp` in this scope
.extend(app_ctx.blueprint.server.response_headers.clone());

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Check Examples

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-gnu

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-arm64-msvc

cannot find value `app_ctx` in this scope

Check failure on line 105 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-gnu

cannot find value `app_ctx` in this scope

}

// Insert Cookie Headers
if let Some(ref cookie_headers) = req_ctx.cookie_headers {

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Check Examples

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-gnu

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-arm64-msvc

cannot find value `req_ctx` in this scope

Check failure on line 109 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-gnu

cannot find value `req_ctx` in this scope
let cookie_headers = cookie_headers.lock().unwrap();
resp.headers_mut().extend(cookie_headers.deref().clone());
}
resp.headers_mut().extend(cookie_headers.defef().clone());

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Check Examples

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-gnu

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-arm64-msvc

cannot find value `resp` in this scope

Check failure on line 111 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-gnu

cannot find value `resp` in this scope
}
Comment on lines +99 to +112
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The function update_response_headers is called correctly in one instance and incorrectly in another due to a missing reference in the app_ctx parameter. This needs to be corrected to ensure consistency with the updated function signature.

Analysis chain

Parameter changes and typo correction in update_response_headers function are appropriate. Verify that the new parameters are correctly used in all calls to this function.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for incorrect usage of the old parameters.
rg --type rust $'update_response_headers\\('

Length of output: 295


// Insert Experimental Headers
req_ctx.extend_x_headers(resp.headers_mut());

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Check Examples

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Check Examples

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-gnu

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-gnu

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-arm64-msvc

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-arm64-msvc

cannot find value `resp` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-gnu

cannot find value `req_ctx` in this scope

Check failure on line 114 in src/http/request_handler.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-gnu

cannot find value `resp` in this scope
}

#[tracing::instrument(skip_all, fields(otel.name = "graphQL", otel.kind = ?SpanKind::Server))]
pub async fn graphql_request<T: DeserializeOwned + GraphQLRequestLike>(
async fn handle_graphql_request<T: DeserializeOwned + GraphQLRequestLike>(
req: Request<Body>,
app_ctx: &AppContext,
req_counter: &mut RequestCounter,
) -> Result<Response<Body>> {
)-> Result <Response<Body>> {
req_counter.set_http_route("/graphql");
let req_ctx = Arc::new(create_request_context(&req, app_ctx));
let bytes = hyper::body::to_bytes(req.into_body()).await?;
let graphql_request = serde_json::from_slice::<T>(&bytes);

match graphql_request {
Ok(request) => {
let mut response = request.data(req_ctx.clone()).execute(&app_ctx.schema).await;

response = update_cache_control_header(response, app_ctx, req_ctx.clone());
let mut resp = response.to_response()?;
update_response_headers(&mut resp, &req_ctx, app_ctx);
Expand Down Expand Up @@ -260,11 +259,8 @@
}

match *req.method() {
// NOTE:
// The first check for the route should be for `/graphql`
// This is always going to be the most used route.
hyper::Method::POST if req.uri().path() == "/graphql" => {
graphql_request::<T>(req, app_ctx.as_ref(), req_counter).await
handle_graphql_request::<T>(req, app_ctx.as_ref(), req_counter).await
}
hyper::Method::POST
if app_ctx.blueprint.server.enable_showcase
Expand All @@ -276,9 +272,8 @@
Err(res) => return Ok(res),
};

graphql_request::<T>(req, &app_ctx, req_counter).await
handle_graphql_request::<T>(req, &app_ctx, req_counter).await
}

hyper::Method::GET => {
if let Some(TelemetryExporter::Prometheus(prometheus)) =
app_ctx.blueprint.telemetry.export.as_ref()
Expand Down
Loading