Skip to content

Commit 6ac4be0

Browse files
committed
Fix raw internal requests so they return transformed content.
Signed-off-by: Jason Lewis <[email protected]>
1 parent e737b92 commit 6ac4be0

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- Routes are now added to the correct groups and matched correctly.
1818
- OPTION requests are now handled correctly for API routes so preflights will no longer fail.
1919
- Eager loading for Fractal transformers now checks the available includes before attempting to load.
20+
- Raw internal requests now have the content run through any transformers as was initially described when implemented.
2021

2122
##### Changed
2223

src/Dispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ protected function dispatch(InternalRequest $request)
539539
$this->clearCachedFacadeInstance();
540540

541541
try {
542-
$response = $this->router->dispatch($request, $this->raw);
542+
$response = $this->router->dispatch($request);
543543

544544
if (! $response->isSuccessful()) {
545545
throw new InternalHttpException($response);

src/Routing/Router.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,12 @@ public function addExistingRoutes(IlluminateRouteCollection $routes)
194194
* or an API response.
195195
*
196196
* @param \Illuminate\Http\Request $request
197-
* @param bool $raw
198197
*
199198
* @throws \Exception
200199
*
201200
* @return \Illuminate\Http\Response|\Dingo\Api\Http\Response
202201
*/
203-
public function dispatch(Request $request, $raw = false)
202+
public function dispatch(Request $request)
204203
{
205204
if (! $this->isApiRequest($request)) {
206205
return parent::dispatch($request);
@@ -227,17 +226,15 @@ public function dispatch(Request $request, $raw = false)
227226
// formatter exists for the requested response format. If not
228227
// then we'll revert to the default format because we are
229228
// most likely formatting an error response.
230-
if (! $raw) {
231-
if (! $response->hasFormatter($format)) {
232-
$format = $this->properties->getFormat();
233-
}
229+
if (! $response->hasFormatter($format)) {
230+
$format = $this->properties->getFormat();
231+
}
234232

235-
$response->getFormatter($format)
236-
->setRequest($request)
237-
->setResponse($response);
233+
$response->getFormatter($format)
234+
->setRequest($request)
235+
->setResponse($response);
238236

239-
$response = $response->morph($format);
240-
}
237+
$response = $response->morph($format);
241238

242239
return $response;
243240
}

0 commit comments

Comments
 (0)