Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.php_cs.cache
.idea
composer.lock
phpunit.xml
storage
Expand Down
14 changes: 14 additions & 0 deletions src/Http/Response/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,20 @@ public function errorUnauthorized($message = 'Unauthorized')
$this->error($message, 401);
}

/**
* Return a 405 method not allowed error.
*
* @param string $message
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*
* @return void
*/
public function errorMethodNotAllowed($message = 'Method Not Allowed')
{
$this->error($message, 405);
}

/**
* Call magic methods beginning with "with".
*
Expand Down
1 change: 0 additions & 1 deletion src/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Dingo\Api\Contract\Routing\Adapter;
use Illuminate\Routing\ControllerInspector;
use Dingo\Api\Contract\Debug\ExceptionHandler;
use Dingo\Api\Http\Parser\Accept as AcceptParser;
use Illuminate\Http\Response as IlluminateResponse;
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;

Expand Down
8 changes: 8 additions & 0 deletions tests/Http/Response/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ public function testUnauthorizedThrowsHttpException()
$this->factory->errorUnauthorized();
}

/**
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function testMethodNotAllowedThrowsHttpException()
{
$this->factory->errorMethodNotAllowed();
}

public function testMakingArrayResponse()
{
$response = $this->factory->array(['foo' => 'bar']);
Expand Down