Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

Commit

Permalink
Merge pull request #20 from dpobel/20X-30X-response
Browse files Browse the repository at this point in the history
fix: consider 30X as successful HTTP status code
  • Loading branch information
RETFU authored Dec 3, 2018
2 parents c459428 + f8c940b commit c3a0823
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"symfony/http-kernel": "^3.0",
"symfony/serializer": "^3.0",
"symfony/property-access": "^3.0",
"symfony/yaml": "^3.0",
"jrfnl/PHP-cast-to-type": "^2.0",
"willdurand/negotiation": "^2.0",
"ralouphie/getallheaders": "^2.0",
Expand All @@ -27,13 +28,13 @@
},
"suggest": {
"silex/silex": "To use the Silex Router",
"alecsammon/php-raml-parser": "To use the RAML APISpec"
"raml-org/raml-php-parser": "To use the RAML APISpec"
},
"require-dev": {
"atoum/atoum": "^3.0",
"atoum/stubs": "*",
"silex/silex": "^2.0",
"alecsammon/php-raml-parser": "^2.2",
"raml-org/raml-php-parser": "^2.2",
"friendsofphp/php-cs-fixer": "^2.0",
"squizlabs/php_codesniffer": "^2.0",
"atoum/reports-extension": "^3.0"
Expand Down
9 changes: 4 additions & 5 deletions src/RREST.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,11 @@ protected function getResponse(RouterInterface $router, $statusCodeSucess, $form
protected function getStatusCodeSuccess()
{
$statusCodes = $this->apiSpec->getStatusCodes();
//find a 20x code
$statusCodes20x = array_filter($statusCodes, function ($value) {
return preg_match('/20\d?/', $value);
$successfulStatusCodes = array_filter($statusCodes, function ($value) {
return preg_match('/^[23]0\d?$/', $value);
});
if (count($statusCodes20x) === 1) {
return (int) array_pop($statusCodes20x);
if (count($successfulStatusCodes) === 1) {
return (int) array_pop($successfulStatusCodes);
} else {
throw new \RuntimeException('You can\'t define multiple 20x for one resource path!');
}
Expand Down

0 comments on commit c3a0823

Please sign in to comment.