mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Added functional-php library
This commit is contained in:
@@ -20,8 +20,8 @@ use Shlinkio\Shlink\Rest\Util\RestUtils;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
use Zend\Expressive\Router\RouteResult;
|
||||
use Zend\I18n\Translator\TranslatorInterface;
|
||||
use function Functional\contains;
|
||||
use function implode;
|
||||
use function Shlinkio\Shlink\Common\contains;
|
||||
use function sprintf;
|
||||
|
||||
class AuthenticationMiddleware implements MiddlewareInterface, StatusCodeInterface, RequestMethodInterface
|
||||
@@ -72,7 +72,7 @@ class AuthenticationMiddleware implements MiddlewareInterface, StatusCodeInterfa
|
||||
if ($routeResult === null
|
||||
|| $routeResult->isFailure()
|
||||
|| $request->getMethod() === self::METHOD_OPTIONS
|
||||
|| contains($routeResult->getMatchedRouteName(), $this->routesWhitelist)
|
||||
|| contains($this->routesWhitelist, $routeResult->getMatchedRouteName())
|
||||
) {
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use function array_shift;
|
||||
use function explode;
|
||||
use function Functional\contains;
|
||||
use function parse_str;
|
||||
use function Shlinkio\Shlink\Common\contains;
|
||||
use function Shlinkio\Shlink\Common\json_decode;
|
||||
use function trim;
|
||||
|
||||
@@ -32,17 +32,17 @@ class BodyParserMiddleware implements MiddlewareInterface, RequestMethodInterfac
|
||||
$currentParams = $request->getParsedBody();
|
||||
|
||||
// In requests that do not allow body or if the body has already been parsed, continue to next middleware
|
||||
if (! empty($currentParams) || contains($method, [
|
||||
if (! empty($currentParams) || contains([
|
||||
self::METHOD_GET,
|
||||
self::METHOD_HEAD,
|
||||
self::METHOD_OPTIONS,
|
||||
])) {
|
||||
], $method)) {
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
// If the accepted content is JSON, try to parse the body from JSON
|
||||
$contentType = $this->getRequestContentType($request);
|
||||
if (contains($contentType, ['application/json', 'text/json', 'application/x-json'])) {
|
||||
if (contains(['application/json', 'text/json', 'application/x-json'], $contentType)) {
|
||||
return $handler->handle($this->parseFromJson($request));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user