Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit c68f944

Browse files
committed
Merge branch 'hotfix/276' into develop
Forward port #276
2 parents 0a26fd3 + 2634cfc commit c68f944

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

doc/book/api.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,33 @@ class Response
7373
Like the `Request` and `ServerRequest`, responses are immutable. Any methods that would change state
7474
— those prefixed with `with` and `without` — all return a new instance with the changes requested.
7575

76-
### StringResponse (factory)
76+
### HtmlResponse and JsonResponse
7777

7878
- Added in 1.1.0
7979

8080
The most common use case in server-side applications for generating responses is to provide a string
81-
to use for the response, typically HTML or data to serialize as JSON. `Zend\Diactoros\Response\StringResponse`
82-
exists to facilitate these use cases:
81+
to use for the response, typically HTML or data to serialize as JSON. `Zend\Diactoros\Response\HtmlResponse` and `Zend\Diactoros\Response\JsonResponse` exist to facilitate these use cases:
8382

8483
```php
85-
$htmlResponse = StringResponse::html($html);
84+
$htmlResponse = new HtmlResponse($html);
8685

87-
$jsonResponse = StringResponse::json($data);
86+
$jsonResponse = new JsonResponse($data);
8887
```
8988

9089
In the first example, you will receive a response with a stream containing the HTML; additionally,
9190
the `Content-Type` header will be set to `text/html`. In the second case, the stream will contain a
9291
stream containing the JSON-serialized `$data`, and have a `Content-Type` header set to
9392
`application/json`.
9493

95-
Both factory methods allow passing the HTTP status, as well as any headers you want to specify,
94+
Both objects allow passing the HTTP status, as well as any headers you want to specify,
9695
including the `Content-Type` header:
9796

9897
```php
99-
$htmlResponse = StringResponse::html($html, 404, [
98+
$htmlResponse = new HtmlResponse($html, 404, [
10099
'Content-Type' => [ 'application/xhtml+xml' ],
101100
]);
102101

103-
$jsonResponse = StringResponse::json($data, 422, [
102+
$jsonResponse = new JsonResponse($data, 422, [
104103
'Content-Type' => [ 'application/problem+json' ],
105104
]);
106105
```

0 commit comments

Comments
 (0)