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

feat: Add support for additional headers in API requests #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tharropoulos
Copy link
Contributor

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:

  1. New configuration option in configuration.py:
    • additional_headers: A dictionary to specify custom headers to be included in all API requests.

Code Changes:

  1. In src/typesense/configuration.py:

    • Added additional_headers to the ConfigDict type definition.
    • Updated the Configuration class to include an additional_headers attribute, initialized from the config dictionary.
  2. In src/typesense/request_handler.py:

    • Modified the RequestHandler._execute_request method to include the additional_headers from the configuration in all outgoing requests.
  3. In tests/api_call_test.py:

    • Added a new test case test_additional_headers to verify that additional headers from the configuration are correctly included in API requests.
  4. In tests/configuration_test.py:

    • Updated the test_configuration_explicit test to include additional_headers in the configuration and expected output.

Documentation Updates:

  1. In src/typesense/configuration.py:
    • Added documentation for the new additional_headers configuration option in the ConfigDict class docstring.

##PR Checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant