summaryrefslogtreecommitdiff
path: root/http/api.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-01-20 12:51:45 +0100
committeremkael <emkael@tlen.pl>2019-01-20 12:51:45 +0100
commit822f9eb854f6d4fcda3d22bd0f4705b4a587ddd5 (patch)
tree151d029475fe66e435b12ea8cc10e986aff86cfd /http/api.php
parentf0b7c5b99748ad654c9c180ac4486a03dc38a3a8 (diff)
Ensuring JSON output on error, setting Content-Type
Diffstat (limited to 'http/api.php')
-rw-r--r--http/api.php5
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)));
//}