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] Provide an easier way to change an Provider's http headers #1296

Open
alexfertel opened this issue Sep 16, 2024 · 0 comments
Open
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
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

No branches or pull requests

1 participant