pdnsmanager/backend/src/controllers/NotAllowed.php
2018-03-23 16:34:25 +01:00

19 lines
588 B
PHP

<?php
namespace Controllers;
require '../vendor/autoload.php';
class NotAllowed
{
public function __invoke(\Slim\Container $c)
{
return function ($request, $response, $methods) use ($c) {
$c->logger->warning('Method ' . $request->getMethod() . ' is not valid for ' . $request->getUri()->getPath());
return $c['response']
->withHeader('Allow', \implode(', ', $methods))
->withJson(array('error' => 'Method ' . $request->getMethod() . ' is not valid use on of ' . implode(', ', $methods)), 405);
};
}
}