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

Add support for building query parameters in the get method of ClientHandler #10

Open
Thavarshan opened this issue Nov 22, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Thavarshan
Copy link
Owner

Description

Currently, the get method in the ClientHandler class does not provide a simple mechanism to include query parameters in GET requests. This feature request proposes adding support for passing an array of key-value pairs as an argument to dynamically construct the query parameter section of the URL.

Proposed Feature Details

  • New Functionality: Enhance the get method to accept an optional associative array for query parameters.
    • The provided array will be converted into a URL query string and appended to the requested endpoint.
    • The library should handle proper URL encoding to ensure compatibility with special characters.

Example Usage

// Example input
$queryParams = [
    'userId' => '123',
    'status' => 'active'
];

// Proposed syntax
$clientHandler->get('/endpoint', ['query' => $queryParams]);

// Expected constructed URL
// /endpoint?userId=123&status=active

Benefits

  • Improved Developer Experience: Simplifies the process of adding query parameters to GET requests.
  • Error Reduction: Prevents common mistakes associated with manual query string concatenation.
  • Consistency: Aligns with standard patterns in modern HTTP client libraries.

Additional Considerations

  • Encoding: Ensure that query keys and values are URL-encoded to prevent issues with reserved characters or special symbols.
  • Backward Compatibility: Maintain the current behavior of the get method for cases where no query parameters are passed.
  • Documentation: Update the library documentation to include examples of this new functionality.
@Thavarshan Thavarshan added the enhancement New feature or request label Nov 22, 2024
@Thavarshan Thavarshan self-assigned this Nov 22, 2024
@Thavarshan Thavarshan changed the title Add support for building query parameters in the get method of ClientHandler Add support for building query parameters in the get method of ClientHandler Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant