friendica-addons/advancedcontentfilter/src/middlewares.php
Hypolite Petovan b02724f867 [advancedcontentfilter] Add addon files
- Add hooks
- Add mini-API module powered by Slim
- Add addon settings page powered by VueJS
- Add translation strings
- Add help page
2018-04-16 22:21:51 -04:00

31 lines
814 B
PHP

<?php
$container = $slim->getContainer();
// Error handler based off https://stackoverflow.com/a/48135009/757392
$container['errorHandler'] = function () {
return function(Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response, Exception $exception)
{
$responseCode = 500;
if (is_a($exception, 'Friendica\Network\HTTPException')) {
$responseCode = $exception->httpcode;
}
$errors['message'] = $exception->getMessage();
$errors['responseCode'] = $responseCode;
return $response
->withStatus($responseCode)
->withJson($errors);
};
};
$container['notFoundHandler'] = function () {
return function ()
{
throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('Method not found'));
};
};