You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR was merged into the 6.3 branch.
Discussion
----------
[HttpClient] Add `UriTemplateHttpClient`
| Q | A
| ------------- | ---
| Branch? | 6.3
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
This PR adds `UriTemplateHttpClient` to ease using URI templates (see https://www.rfc-editor.org/rfc/rfc6570) with `symfony/http-client`.
The goal is not to reimplement the RFC 6570 but to provide a better DX. A vendor has to be installed to expand the urls and we do not impose which one.
The simple usage is:
```php
(new UriTemplateHttpClient())
->request('GET', 'https//ccc.tld/{resource}{?page}', [
'vars' => [
'resource' => 'users',
'page' => 3,
],
]);
// the requested url is https//ccc.tld/users?page=3
```
In a full framework context, all HTTP clients are decorated by `UriTemplateHttpClient`. The support is transparent and enabled globally.
It's possible to configure a custom expander by redefining the `http_client.uri_template_expander` alias.
Commits
-------
803a54e51e [HttpClient] Add UriTemplateHttpClient
0 commit comments