Skip to content

Commit 5ce47c4

Browse files
committed
feat: update response docs
1 parent e403cc8 commit 5ce47c4

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/docs/http/response.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,20 @@ These responses are used to redirect the user to another URL. You can create a r
185185

186186
::: code-group
187187

188-
```php [Functional Mode]
189-
response()->redirect('https://example.com');
188+
```php:no-line-numbers [Functional Mode]
189+
response()->redirect('/example'); // path within the app
190+
response()->redirect(['example']); // redirect with route name
191+
response()->redirect('https://example.com'); // redirect to external URL
190192
```
191193

192-
```php [Leaf Instance]
193-
$app->response()->redirect('https://example.com');
194+
```php:no-line-numbers [Leaf Instance]
195+
$app->response()->redirect('/example'); // path within the app
196+
$app->response()->redirect(['example']); // redirect with route name
197+
$app->response()->redirect('https://example.com'); // redirect to external URL
194198
```
195199

200+
:::
201+
196202
### File download responses
197203

198204
It's not so unusual to want to send a file to the user for download. You can create a file download response using the `download()` method. This method accepts 3 parameters:
@@ -203,13 +209,13 @@ It's not so unusual to want to send a file to the user for download. You can cre
203209

204210
::: code-group
205211

206-
```php [Functional Mode]
212+
```php:no-line-numbers [Functional Mode]
207213
response()->download('path/to/file.pdf');
208214
209215
response()->download('path/to/file.pdf', 'new-filename.pdf', 200);
210216
```
211217

212-
```php [Leaf Instance]
218+
```php:no-line-numbers [Leaf Instance]
213219
$app->response()->download('path/to/file.pdf');
214220
215221
$app->response()->download('path/to/file.pdf', 'new-filename.pdf', 200);
@@ -223,11 +229,11 @@ These responses are used when you don't want to return any content to the user.
223229

224230
::: code-group
225231

226-
```php [Functional Mode]
232+
```php:no-line-numbers [Functional Mode]
227233
response()->noContent();
228234
```
229235

230-
```php [Leaf Instance]
236+
```php:no-line-numbers [Leaf Instance]
231237
$app->response()->noContent();
232238
```
233239

@@ -242,11 +248,11 @@ XML responses can be created using the `xml()` method. This method accepts 2 par
242248

243249
::: code-group
244250

245-
```php [Functional Mode]
251+
```php:no-line-numbers [Functional Mode]
246252
response()->xml('<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0.0" />');
247253
```
248254

249-
```php [Leaf Instance]
255+
```php:no-line-numbers [Leaf Instance]
250256
$app->response()->xml('<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0.0" />');
251257
```
252258

@@ -265,15 +271,15 @@ Leaf allows you to set headers for your response directly from the response obje
265271

266272
::: code-group
267273

268-
```php [Functional Mode]
274+
```php:no-line-numbers [Functional Mode]
269275
response()->withHeader('Content-Type', 'application/json');
270276
response()->withHeader([
271277
'Content-Type' => 'application/json',
272278
'X-Custom-Header' => 'Custom Value'
273279
]);
274280
```
275281

276-
```php [Leaf Instance]
282+
```php:no-line-numbers [Leaf Instance]
277283
$app->response()->withHeader('Content-Type', 'application/json');
278284
$app->response()->withHeader([
279285
'Content-Type' => 'application/json',

0 commit comments

Comments
 (0)