diff options
author | emkael <emkael@tlen.pl> | 2019-01-20 12:51:45 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-01-20 12:51:45 +0100 |
commit | 822f9eb854f6d4fcda3d22bd0f4705b4a587ddd5 (patch) | |
tree | 151d029475fe66e435b12ea8cc10e986aff86cfd /http | |
parent | f0b7c5b99748ad654c9c180ac4486a03dc38a3a8 (diff) |
Ensuring JSON output on error, setting Content-Type
Diffstat (limited to 'http')
-rw-r--r-- | http/api.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/http/api.php b/http/api.php index ab8d002..e83420b 100644 --- a/http/api.php +++ b/http/api.php @@ -193,11 +193,11 @@ function run($parameters) { } catch (ParametersException $e) { http_response_code(400); - die($e->getMessage()); + die(json_encode($e->getMessage())); } catch (Exception $e) { http_response_code(500); - die($e->getMessage()); + die(json_encode($e->getMessage())); } } @@ -205,6 +205,7 @@ function run($parameters) { http_response_code(405); die('API only accepts POST requests'); } else {*/ + header('Content-Type: application/json'); print(json_encode(run($_REQUEST))); //} |