10000 Merge branch 'release/1.0.0' into main · alescx/laravel-json-api-core@b5cf6e0 · GitHub
[go: up one dir, main page]

Skip to content

Commit b5cf6e0

Browse files
committed
Merge branch 'release/1.0.0' into main
2 parents d2ccf9c + 2c00fc9 commit b5cf6e0

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file. This project adheres to
44
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).
55

6+
## [1.0.0] - 2021-07-31
7+
8+
### Fixed
9+
10+
- Ensure the `DataResponse` class passes on its created flag if its data member is already a `JsonApiResource`.
11+
- Only add the `Location` header to a response if the resource has a `self` URL. Previously the header would be set with
12+
a `null` value.
13+
614
## [1.0.0-beta.5] - 2021-07-10
715

816
### Added

src/Core/Responses/DataRespon E47C se.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ private function prepareDataResponse($request)
137137
}
138138

139139
if ($this->value instanceof JsonApiResource) {
140-
return $this->value->prepareResponse($request);
140+
return $this->value
141+
->prepareResponse($request)
142+
->withCreated($this->created);
141143
}
142144

143145
$resources = $this->server()->resources();

src/Core/Responses/Internal/ResourceResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ protected function headers(): array
131131
->merge($this->headers ?: [])
132132
->all();
133133

134-
if ($this->resourceWasCreated()) {
135-
$headers['Location'] = $this->resource->selfUrl();
134+
if ($this->resourceWasCreated() && $selfUrl = $this->resource->selfUrl()) {
135+
$headers['Location'] = $selfUrl;
136136
}
137137

138138
return $headers;

0 commit comments

Comments
 (0)
0