Skip to content

Conversation

@rohankmr414
Copy link

This pull request adds support for HTTP middleware in the iceberg-catalog-rest crate, allowing users to inject custom middleware (such as logging, retries, or authentication) into HTTP requests using the reqwest-middleware crate. The implementation is feature-gated and includes documentation, configuration options, and tests for middleware support.

Middleware support:

  • Added an optional middleware feature to Cargo.toml that enables integration with the reqwest-middleware crate for custom HTTP middleware capabilities. [1] [2]
  • Extended the RestCatalogBuilder and RestCatalogConfig structs to support a middleware_client field, and provided a with_middleware_client method for configuration. [1] [2] [3]
  • Updated the internal HttpClient to use the middleware client when configured, including logic in the execute method to route requests through middleware if present. [1] [2] [3] [4]

Documentation:

  • Added a new section to the README.md with usage instructions and examples for enabling and using middleware support.

Testing:

  • Introduced new tests to verify middleware client integration and to demonstrate how custom middleware (such as request counting) can intercept requests.

Introduces an optional `middleware` feature to enable custom HTTP middleware for the REST catalog client.

This integration with `reqwest-middleware` allows users to inject custom logic into HTTP requests, facilitating advanced functionalities such as logging, retry mechanisms, rate limiting, and custom authentication.

A `with_middleware_client` method is added to `RestCatalogBuilder` for easy configuration.
Reorders import statements within a middleware test for better consistency and readability.
@rohankmr414
Copy link
Author

This change is required to support authentication headers in scenarios such as projected Kubernetes service account tokens. These tokens are rotated frequently (typically every hour), so it’s important for clients to be able to watch the token file and update the headers dynamically as the token changes. This middleware support will enable such use cases seamlessly.

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