18e6796726
* REST API routes are handle by Slim. * Every API controller go through ApiMiddleware which handles security. * First service implemented `/info`, for tests purpose.
34 lines
784 B
PHP
34 lines
784 B
PHP
<?php
|
|
|
|
namespace Shaarli\Api\Exceptions;
|
|
|
|
/**
|
|
* Class ApiAuthorizationException
|
|
*
|
|
* Request not authorized, return a 401 HTTP code.
|
|
*/
|
|
class ApiAuthorizationException extends ApiException
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getApiResponse()
|
|
{
|
|
$this->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;
|
|
}
|
|
}
|