mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
report 405s correctly
This commit is contained in:
parent
4f662ba9e1
commit
dcd3e22ad4
5 changed files with 31 additions and 3 deletions
|
@ -60,6 +60,12 @@ class Controller
|
||||||
{
|
{
|
||||||
return NavActions::execute404();
|
return NavActions::execute404();
|
||||||
}
|
}
|
||||||
|
catch (\Routing\HttpMethodNotAllowedException $e)
|
||||||
|
{
|
||||||
|
Response::setStatus(405);
|
||||||
|
Response::setHeader('Allow', implode(', ', $e->getAllowedMethods()));
|
||||||
|
return ['page/404'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function getRouterWithRoutes(): \Routing\RouteCollector
|
protected static function getRouterWithRoutes(): \Routing\RouteCollector
|
||||||
|
|
|
@ -93,6 +93,7 @@ news:
|
||||||
next: Next
|
next: Next
|
||||||
prev: Previous
|
prev: Previous
|
||||||
page:
|
page:
|
||||||
|
badmethod: HTTP method not allowed
|
||||||
faq:
|
faq:
|
||||||
back: Back to FAQ
|
back: Back to FAQ
|
||||||
header: Frequently Asked Questions
|
header: Frequently Asked Questions
|
||||||
|
|
|
@ -175,7 +175,7 @@ class Dispatcher
|
||||||
|
|
||||||
$this->matchedRoute = $routes;
|
$this->matchedRoute = $routes;
|
||||||
|
|
||||||
throw new HttpMethodNotAllowedException('Allow: ' . implode(', ', array_keys($routes)));
|
throw new HttpMethodNotAllowedException(array_keys($routes), 'Method not allowed');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Routing;
|
namespace Routing;
|
||||||
|
|
||||||
class HttpMethodNotAllowedException extends HttpException {}
|
class HttpMethodNotAllowedException extends HttpException
|
||||||
|
{
|
||||||
|
protected $allowedMethods;
|
||||||
|
|
||||||
|
public function __construct(array $allowedMethods, $message, $code, Exception $previous)
|
||||||
|
{
|
||||||
|
$this->allowedMethods = $allowedMethods;
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllowedMethods()
|
||||||
|
{
|
||||||
|
return $this->allowedMethods;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
7
view/template/page/405.php
Normal file
7
view/template/page/405.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php echo View::render('nav/_header', ['isDark' => false]) ?>
|
||||||
|
<main>
|
||||||
|
<div class="content">
|
||||||
|
<h1>{{page.badmethod}}</h1>
|
||||||
|
<p>{{page.funnier}}</p>
|
||||||
|
</div>
|
||||||
|
</main>
|
Loading…
Add table
Reference in a new issue