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
{{ message }}
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: doc/book/api.md
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,34 +73,33 @@ class Response
73
73
Like the `Request` and `ServerRequest`, responses are immutable. Any methods that would change state
74
74
— those prefixed with `with` and `without`— all return a new instance with the changes requested.
75
75
76
-
### StringResponse (factory)
76
+
### HtmlResponse and JsonResponse
77
77
78
78
- Added in 1.1.0
79
79
80
80
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:
83
82
84
83
```php
85
-
$htmlResponse = StringResponse::html($html);
84
+
$htmlResponse = new HtmlResponse($html);
86
85
87
-
$jsonResponse = StringResponse::json($data);
86
+
$jsonResponse = new JsonResponse($data);
88
87
```
89
88
90
89
In the first example, you will receive a response with a stream containing the HTML; additionally,
91
90
the `Content-Type` header will be set to `text/html`. In the second case, the stream will contain a
92
91
stream containing the JSON-serialized `$data`, and have a `Content-Type` header set to
93
92
`application/json`.
94
93
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,
0 commit comments