feat: Add support for additional headers in API requests #60
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.
What is this?
This pull request introduces the ability to include custom headers in API requests to Typesense. This enhancement provides greater flexibility for users who need to send specific headers with their requests, such as for authentication or custom metadata. This tries to address the feature request discussed on #54
Changes
Added Features:
configuration.py
:additional_headers
: A dictionary to specify custom headers to be included in all API requests.Code Changes:
In
src/typesense/configuration.py
:additional_headers
to theConfigDict
type definition.Configuration
class to include anadditional_headers
attribute, initialized from the config dictionary.In
src/typesense/request_handler.py
:RequestHandler._execute_request
method to include theadditional_headers
from the configuration in all outgoing requests.In
tests/api_call_test.py
:test_additional_headers
to verify that additional headers from the configuration are correctly included in API requests.In
tests/configuration_test.py
:test_configuration_explicit
test to includeadditional_headers
in the configuration and expected output.Documentation Updates:
src/typesense/configuration.py
:additional_headers
configuration option in theConfigDict
class docstring.##PR Checklist