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

[10.x] Add PendingRequest withHeader() method #47474

Merged
merged 5 commits into from
Jun 18, 2023

Conversation

ralphjsmit
Copy link
Contributor

This PR adds a convenience withHeader() method on the Http client PendingRequest class. I think that the majority of the time people only add a single header when using the withHeaders() method, so we could as well have a convenient method that saves 2 lines.

Before:

Http::baseUrl(config('services.active-campaign.endpoint') . '/api/3')
    ->withHeaders([
        'Api-Token' => config('services.active-campaign.token')
    ])
    ->acceptJson();

After:

Http::baseUrl(config('services.active-campaign.endpoint') . '/api/3')
    ->withHeader('Api-Token', config('services.active-campaign.token'))
    ->acceptJson();

Thanks!

@taylorotwell taylorotwell merged commit 0738aa1 into laravel:10.x Jun 18, 2023
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.

2 participants