From cfa9b40bc1fceec140af77a128ab772f0d9ff11a Mon Sep 17 00:00:00 2001 From: Override-6 Date: Fri, 8 Dec 2023 22:54:34 +0100 Subject: [PATCH] WIP --- src/Api/API.php | 1 + src/Api/Controller/APIAccountsController.php | 1 - src/Core/Control.php | 3 ++- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Api/API.php b/src/Api/API.php index 6fd7b71..d751c75 100644 --- a/src/Api/API.php +++ b/src/Api/API.php @@ -17,6 +17,7 @@ class API { header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers: *'); + foreach ($response->getHeaders() as $header => $value) { header("$header: $value"); } diff --git a/src/Api/Controller/APIAccountsController.php b/src/Api/Controller/APIAccountsController.php index 7b70f7d..cfaa3e0 100644 --- a/src/Api/Controller/APIAccountsController.php +++ b/src/Api/Controller/APIAccountsController.php @@ -49,7 +49,6 @@ class APIAccountsController { }); } - /** * @param int $userId * @return HttpResponse given user information. diff --git a/src/Core/Control.php b/src/Core/Control.php index 7456202..a8ac6c6 100644 --- a/src/Core/Control.php +++ b/src/Core/Control.php @@ -25,6 +25,7 @@ class Control { if (!$payload_obj instanceof \stdClass) { $fail = new ValidationFail("bad-payload", "request body is not a valid json object"); return $errorFactory->apply([$fail]); + } $payload = get_object_vars($payload_obj); return self::runCheckedFrom($payload, $schema, $run, $errorFactory); @@ -36,7 +37,6 @@ class Control { * @param array $schema an array of `fieldName => DefaultValidators` which represents the request object schema * @param callable(HttpRequest): HttpResponse $run the callback to run if the request is valid according to the given schema. * The callback must accept an HttpRequest, and return an HttpResponse object. -<<<<<<< HEAD:src/Core/Control.php * @param ControlSchemaErrorResponseFactory $errorFactory an error factory to use if the request does not validate the required schema * @return HttpResponse */ @@ -46,6 +46,7 @@ class Control { if (!empty($fails)) { return $errorFactory->apply($fails); + } return call_user_func_array($run, [$request]);