Skip to content

Commit 339f4bf

Browse files
committed
document uri templates
1 parent 21abe56 commit 339f4bf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

http-client.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ The `Illuminate\Http\Client\Response` object also implements the PHP `ArrayAcces
5858

5959
return Http::get('http://example.com/users/1')['name'];
6060

61+
<a name="uri-templates"></a>
62+
#### URI Templates
63+
64+
The HTTP client also allows you to construct request URLs using the [URI template specification](https://www.rfc-editor.org/rfc/rfc6570). To define the URL parameters that can be expanded by your URI template, you may use the `withUrlParameters` method:
65+
66+
```php
67+
Http::withUrlParameters([
68+
'endpoint' => 'https://laravel.com',
69+
'page' => 'docs',
70+
'version' => '9.x',
71+
'topic' => 'validation',
72+
])->get('{+endpoint}/{page}/{version}/{topic}');
73+
```
74+
6175
<a name="dumping-requests"></a>
6276
#### Dumping Requests
6377

0 commit comments

Comments
 (0)