typesense-python
typesense-python copied to clipboard
feat: Add support for additional headers in API requests
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:
-
New configuration option in
configuration.py:-
additional_headers: A dictionary to specify custom headers to be included in all API requests.
-
Code Changes:
-
In
src/typesense/configuration.py:- Added
additional_headersto theConfigDicttype definition. - Updated the
Configurationclass to include anadditional_headersattribute, initialized from the config dictionary.
- Added
-
In
src/typesense/request_handler.py:- Modified the
RequestHandler._execute_requestmethod to include theadditional_headersfrom the configuration in all outgoing requests.
- Modified the
-
In
tests/api_call_test.py:- Added a new test case
test_additional_headersto verify that additional headers from the configuration are correctly included in API requests.
- Added a new test case
-
In
tests/configuration_test.py:- Updated the
test_configuration_explicittest to includeadditional_headersin the configuration and expected output.
- Updated the
Documentation Updates:
-
In
src/typesense/configuration.py:- Added documentation for the new
additional_headersconfiguration option in theConfigDictclass docstring.
- Added documentation for the new
##PR Checklist
- [x] I have read and signed the Contributor License Agreement.