Skip to content

Conversation

leek
Copy link
Contributor

@leek leek commented Oct 6, 2025

This PR introduces mergeUrlParameters(array $parameters = []) to Illuminate\Http\Client\PendingRequest.

Today, withUrlParameters() replaces the entire parameter map, which makes it hard to define global parameters (e.g., in a macro) and then add/override endpoint-specific parameters later. The new method merges into the existing map, letting later calls override only the keys they provide.

Backwards compatibility
  • Fully BC: existing withUrlParameters() behavior is unchanged.
  • No impact on public signatures other than the additive new method.
Usage example
Http::macro('service', function () {
    return Http::baseUrl('https://api.example.com')
        ->withUrlParameters(['version' => 'v1', 'tenant' => 'acme']);
});

$response = Http::service()
    ->mergeUrlParameters(['tenant' => 'beta'])
    ->get('/{version}/tenants/{tenant}/users');

Add method to merge URL parameters into existing map.
@leek leek changed the title HTTP Client: add mergeUrlParameters() to combine URL parameters without overwriting [12.x] HTTP Client: add mergeUrlParameters() to combine URL parameters without overwriting Oct 6, 2025
@taylorotwell taylorotwell merged commit 920724c into laravel:12.x Oct 6, 2025
64 checks passed
@taylorotwell
Copy link
Member

I kinda think they should just always merge.

@leek leek deleted the patch-1 branch October 6, 2025 23:16
@guenbakku
Copy link

It looks like that the MR title doesn't quite match the final code. There is no new method mergeUrlParameters; instead, the behavior of withUrlParameters was updated to merge (instead of replace).

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.

3 participants