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

[Feature] Demonstrate HTTP with auth #153

Closed
alexfertel opened this issue Sep 16, 2024 · 0 comments · Fixed by #154
Closed

[Feature] Demonstrate HTTP with auth #153

alexfertel opened this issue Sep 16, 2024 · 0 comments · Fixed by #154
Labels
enhancement New feature or request

Comments

@alexfertel
Copy link
Contributor

Component

provider, pubsub, transports

Describe the feature you would like

I could not figure out a terser way of modifying headers to be sent with each request, and it took me some time to get to this:

    let client = {
        let mut headers = reqwest::header::HeaderMap::new();
        headers.insert(
            "HEADER",
            reqwest::header::HeaderValue::from_static("VALUE"),
        );
        let client = reqwest::Client::builder()
            .default_headers(headers)
            .build()
            .expect("Failed to build reqwest client");
        let http = Http::with_client(client, rpc_url.clone());
        let is_local = http.guess_local();
        RpcClient::new(http, is_local)
    };
    let provider = ProviderBuilder::default().on_client(client);

If there is an easier way to do this, could there be an example? If not, could it be added?

Additional context

No response

@alexfertel alexfertel added the enhancement New feature or request label Sep 16, 2024
@alexfertel alexfertel changed the title [Feature] Provide an easier way to change an http Provider's headers [Feature] Provide an easier way to change an Provider's http headers Sep 17, 2024
@yash-atreya yash-atreya transferred this issue from alloy-rs/alloy Oct 28, 2024
@yash-atreya yash-atreya changed the title [Feature] Provide an easier way to change an Provider's http headers [Feature] Demonstrate HTTP with auth Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant