Skip to content

Add Support for Custom HTTP Client Implementation #17

@oasaph

Description

@oasaph

Description

Currently, the library is tightly coupled to requests.get for fetching flags. We should allow users to provide their own HTTP client implementation for more flexibility.

Goals

  • Allow injection of custom HTTP client
  • Support different HTTP libraries (aiohttp, httpx, etc.)
  • Maintain backward compatibility

Proposed Implementation

  1. Create an abstract base class for flag fetching
  2. Implement the default requests-based fetcher
  3. Allow custom fetcher injection in Flaggle constructor
  4. Add documentation and examples

Example Interface

class FlagFetcher(ABC):
    @abstractmethod
    async def fetch_flags(self, url: str) -> dict:
        pass

flaggle = Flaggle(url="https://api.example.com/flags", fetcher=CustomFetcher())

Acceptance Criteria

  • Abstract base class for flag fetching
  • Default implementation using requests
  • Documentation for custom implementations
  • Unit tests for custom fetcher support

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions