elastic / elasticsearch-rs

Official Elasticsearch Rust Client
https://www.elastic.co/guide/en/elasticsearch/client/rust-api/current/index.html
Apache License 2.0
705 stars 72 forks source link

[ENHANCEMENT] Ability to add HTTP headers to a request #16

Closed russcam closed 4 years ago

russcam commented 4 years ago

Every request made by the client should have the ability to allow a consumer to optionally specify additional HTTP headers to include in the request, for example, X-Opaque-Id.

Possible implementation

Generated builder structs include a HeaderMap field, with an associated function that accepts a header name and value. It may make sense to expose the same signature as the reqwest crate, the HTTP crate being used

pub fn header<K, V>(mut self, key: K, value: V) -> Self
where
    HeaderName: HttpTryFrom<K>,
    HeaderValue: HttpTryFrom<V>,
{
    //...
}