-
-
Notifications
You must be signed in to change notification settings - Fork 327
Feature/set http headers #808 #819
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
Merged
XAMPPRocky
merged 4 commits into
XAMPPRocky:main
from
dmgorsky:feature/set-http-headers-808
Nov 6, 2025
+64
−0
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a44ad6f
added '[package.metadata.github-api].set-headers' section in Cargo.to…
dmgorsky 0274bcd
added '[package.metadata.github-api].set-headers' section in Cargo.to…
dmgorsky 666a71c
Merge remote-tracking branch 'origin/feature/set-http-headers-808' in…
dmgorsky a86d467
renamed [package.metadata.github-api].set-headers to request-headers
dmgorsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
added '[package.metadata.github-api].set-headers' section in Cargo.to…
…ml with an array of http headers necessary to add in lib.rs/`build_request()` (created in build.rs; imported with include!)
- Loading branch information
commit a44ad6faa0d410a07be466a80634cfcf2a14942a
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| use cargo_metadata::MetadataCommand; | ||
| use std::env; | ||
| use std::fs; | ||
| use std::path::Path; | ||
|
|
||
| fn main() { | ||
| println!("cargo:rerun-if-changed=Cargo.toml"); | ||
|
|
||
| let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); // Cargo.toml path | ||
| let manifest_path = Path::new(&manifest_dir).join("Cargo.toml"); | ||
|
|
||
| let metadata = MetadataCommand::new() | ||
| .manifest_path(&manifest_path) | ||
| .exec() | ||
| .expect("failed to parse `cargo metadata`"); | ||
|
|
||
| let root_package = metadata.root_package().unwrap(); | ||
| let custom_metadata = &root_package.metadata; | ||
|
|
||
| let set_headers_array = custom_metadata["github-api"]["set-headers"] | ||
| .as_array() | ||
| .cloned() | ||
| .unwrap_or(Default::default()); | ||
| let set_headers_array = set_headers_array | ||
| .iter() | ||
| .map(|x| x.as_str().unwrap_or_default()) | ||
| .map(|x| { | ||
| // split either by ":" or by ": " | ||
| x.split_once(": ") | ||
| .unwrap_or_else(|| (x.split_once(":")).unwrap_or_default()) | ||
| }) | ||
| .collect::<Vec<(&str, &str)>>(); | ||
| let array_creation_static = format!( | ||
| "pub const _SET_HEADERS_MAP: [(&str, &str); {}] = {:?};", | ||
| &set_headers_array.len(), | ||
| &set_headers_array | ||
| ); | ||
|
|
||
| let out_dir = env::var("OUT_DIR").unwrap(); // build's OUT path | ||
| let dest_path = Path::new(&out_dir).join("headers_metadata.rs"); | ||
| fs::write(&dest_path, array_creation_static) | ||
| .expect(format!("failed to write {}", dest_path.display()).as_str()); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we call this
headersinstead? TOML is declarative not imperative, so you wouldn't include a verb like "set"Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP, how can we make the name more descriptive? Like, 'headers to be set', without documentation.
necessary-headers,request-headers.edit:
request-headers👌