meilisearch / meilisearch-python

Python wrapper for the Meilisearch API
https://meilisearch.com
MIT License
465 stars 85 forks source link

Add custom headers to the python client class #997

Open jroseCCRI opened 3 months ago

jroseCCRI commented 3 months ago

Description Be able to add custom headers into the client when creating a Client object. Essentially we cannot use this python wrapper for our API because there is no way (that I was able to find at least) to insert your own custom headers. In our use case, we have special headers that must be passed into the request in order for any request to enter our host for meilisearch that we are using. Instead, we have to use the python requests library which works, but we would prefer to use the python wrapper that is here. Here is the hard-coded headers for reference: https://github.com/meilisearch/meilisearch-python/blob/4ca3371888026de592f2c3004dc12cd667571e55/meilisearch/_httprequests.py#L22-L25

Basic example If the proposal involves something new or a change, include a basic example. How would you use the feature? In which context? Ideally we could do something like the following: client = Client("host", "key", custom_headers= {"header_key_1": "header_value_1", "header_key_2": "header_value_2"})

Other Any other things you want to add.

curquiza commented 3 months ago

Hello thank you for the suggestion

@sanders41 what do you think (if you are around 😇)?

sanders41 commented 3 months ago

@sanders41 what do you think (if you are around 😇)?

I see no reason not to. I actually already implemented this here and intended to do the same in this package but got busy and forgot. We should be able to more or less copy over what I did.

@jroseCCRI do you have any interest in creating a PR for this?