From 40d68eb42dac96eceb92574ee51fd4e081c30cad Mon Sep 17 00:00:00 2001 From: Xiao Hu Tai Date: Mon, 30 Jul 2018 13:11:53 +0200 Subject: [PATCH] Set correct response header for `menu` and `taxonomy` Since these two actions are not JSON API, we set them to `application/json` for now. Problem is that responses need to be written which will cause a bigger break. --- src/Action/MenuAction.php | 8 ++++++-- src/Action/TaxonomyAction.php | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Action/MenuAction.php b/src/Action/MenuAction.php index eaf0356..2390a61 100644 --- a/src/Action/MenuAction.php +++ b/src/Action/MenuAction.php @@ -44,15 +44,19 @@ public function handle(Request $request) } $menu = $this->boltConfig->get('menu' . $name, false); - + if (! $menu) { throw new ApiNotFoundException( "Menu with name [$name] not found." ); } - return new ApiResponse([ + $response = new ApiResponse([ 'data' => $menu, ], $this->extensionConfig); + + $response->headers->set('Content-Type', 'application/json'); + + return $response; } } diff --git a/src/Action/TaxonomyAction.php b/src/Action/TaxonomyAction.php index 24beb53..7ab1840 100644 --- a/src/Action/TaxonomyAction.php +++ b/src/Action/TaxonomyAction.php @@ -51,8 +51,12 @@ public function handle(Request $request) ); } - return new ApiResponse([ + $response = new ApiResponse([ 'data' => $taxonomy, ], $this->extensionConfig); + + $response->headers->set('Content-Type', 'application/json'); + + return $response; } }