From 18e6796726d73d7dc90ecdd16c181493941f5487 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 15 Dec 2016 10:13:00 +0100 Subject: REST API structure using Slim framework * REST API routes are handle by Slim. * Every API controller go through ApiMiddleware which handles security. * First service implemented `/info`, for tests purpose. --- .../api/exceptions/ApiAuthorizationException.php | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 application/api/exceptions/ApiAuthorizationException.php (limited to 'application/api/exceptions/ApiAuthorizationException.php') diff --git a/application/api/exceptions/ApiAuthorizationException.php b/application/api/exceptions/ApiAuthorizationException.php new file mode 100644 index 00000000..0e3f4776 --- /dev/null +++ b/application/api/exceptions/ApiAuthorizationException.php @@ -0,0 +1,34 @@ +setMessage('Not authorized'); + return $this->buildApiResponse(401); + } + + /** + * Set the exception message. + * + * We only return a generic error message in production mode to avoid giving + * to much security information. + * + * @param $message string the exception message. + */ + public function setMessage($message) + { + $original = $this->debug === true ? ': '. $this->getMessage() : ''; + $this->message = $message . $original; + } +} -- cgit v1.2.3