|
@@ -247,6 +247,22 @@ interface UriInterface
|
247
|
247
|
public function __toString();
|
248
|
248
|
}
|
249
|
249
|
|
|
250
|
+// file: src/Psr/Http/Server/MiddlewareInterface.php
|
|
251
|
+
|
|
252
|
+interface MiddlewareInterface
|
|
253
|
+{
|
|
254
|
+
|
|
255
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface;
|
|
256
|
+}
|
|
257
|
+
|
|
258
|
+// file: src/Psr/Http/Server/RequestHandlerInterface.php
|
|
259
|
+
|
|
260
|
+interface RequestHandlerInterface
|
|
261
|
+{
|
|
262
|
+
|
|
263
|
+ public function handle(ServerRequestInterface $request): ResponseInterface;
|
|
264
|
+}
|
|
265
|
+
|
250
|
266
|
// file: src/Nyholm/Psr7/Factory/Psr17Factory.php
|
251
|
267
|
|
252
|
268
|
final class Psr17Factory implements RequestFactoryInterface, ResponseFactoryInterface, ServerRequestFactoryInterface, StreamFactoryInterface, UploadedFileFactoryInterface, UriFactoryInterface
|
|
@@ -4419,16 +4435,9 @@ class TypeConverter
|
4419
|
4435
|
}
|
4420
|
4436
|
}
|
4421
|
4437
|
|
4422
|
|
-// file: src/Tqdev/PhpCrudApi/Middleware/Base/Handler.php
|
4423
|
|
-
|
4424
|
|
-interface Handler
|
4425
|
|
-{
|
4426
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface;
|
4427
|
|
-}
|
4428
|
|
-
|
4429
|
4438
|
// file: src/Tqdev/PhpCrudApi/Middleware/Base/Middleware.php
|
4430
|
4439
|
|
4431
|
|
-abstract class Middleware implements Handler
|
|
4440
|
+abstract class Middleware implements MiddlewareInterface
|
4432
|
4441
|
{
|
4433
|
4442
|
protected $next;
|
4434
|
4443
|
protected $responder;
|
|
@@ -4441,11 +4450,6 @@ abstract class Middleware implements Handler
|
4441
|
4450
|
$this->properties = $properties;
|
4442
|
4451
|
}
|
4443
|
4452
|
|
4444
|
|
- public function setNext(Handler $handler) /*: void*/
|
4445
|
|
- {
|
4446
|
|
- $this->next = $handler;
|
4447
|
|
- }
|
4448
|
|
-
|
4449
|
4453
|
protected function getArrayProperty(string $key, string $default): array
|
4450
|
4454
|
{
|
4451
|
4455
|
return array_filter(array_map('trim', explode(',', $this->getProperty($key, $default))));
|
|
@@ -4479,7 +4483,7 @@ class VariableStore
|
4479
|
4483
|
|
4480
|
4484
|
// file: src/Tqdev/PhpCrudApi/Middleware/Router/Router.php
|
4481
|
4485
|
|
4482
|
|
-interface Router extends Handler
|
|
4486
|
+interface Router extends RequestHandlerInterface
|
4483
|
4487
|
{
|
4484
|
4488
|
public function register(string $method, string $path, array $handler);
|
4485
|
4489
|
|
|
@@ -4538,13 +4542,7 @@ class SimpleRouter implements Router
|
4538
|
4542
|
|
4539
|
4543
|
public function load(Middleware $middleware) /*: void*/
|
4540
|
4544
|
{
|
4541
|
|
- if (count($this->middlewares) > 0) {
|
4542
|
|
- $next = $this->middlewares[0];
|
4543
|
|
- } else {
|
4544
|
|
- $next = $this;
|
4545
|
|
- }
|
4546
|
|
- $middleware->setNext($next);
|
4547
|
|
- array_unshift($this->middlewares, $middleware);
|
|
4545
|
+ array_push($this->middlewares, $middleware);
|
4548
|
4546
|
}
|
4549
|
4547
|
|
4550
|
4548
|
public function route(ServerRequestInterface $request): ResponseInterface
|
|
@@ -4553,11 +4551,7 @@ class SimpleRouter implements Router
|
4553
|
4551
|
$data = gzcompress(json_encode($this->routes, JSON_UNESCAPED_UNICODE));
|
4554
|
4552
|
$this->cache->set('PathTree', $data, $this->ttl);
|
4555
|
4553
|
}
|
4556
|
|
- $obj = $this;
|
4557
|
|
- if (count($this->middlewares) > 0) {
|
4558
|
|
- $obj = $this->middlewares[0];
|
4559
|
|
- }
|
4560
|
|
- return $obj->handle($request);
|
|
4554
|
+ return $this->handle($request);
|
4561
|
4555
|
}
|
4562
|
4556
|
|
4563
|
4557
|
private function getRouteNumbers(ServerRequestInterface $request): array
|
|
@@ -4570,6 +4564,11 @@ class SimpleRouter implements Router
|
4570
|
4564
|
|
4571
|
4565
|
public function handle(ServerRequestInterface $request): ResponseInterface
|
4572
|
4566
|
{
|
|
4567
|
+ if (count($this->middlewares)) {
|
|
4568
|
+ $handler = array_pop($this->middlewares);
|
|
4569
|
+ return $handler->process($request, $this);
|
|
4570
|
+ }
|
|
4571
|
+
|
4573
|
4572
|
$routeNumbers = $this->getRouteNumbers($request);
|
4574
|
4573
|
if (count($routeNumbers) == 0) {
|
4575
|
4574
|
return $this->responder->error(ErrorCode::ROUTE_NOT_FOUND, $request->getRequestTarget());
|
|
@@ -4599,7 +4598,7 @@ class SimpleRouter implements Router
|
4599
|
4598
|
|
4600
|
4599
|
class AjaxOnlyMiddleware extends Middleware
|
4601
|
4600
|
{
|
4602
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
4601
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
4603
|
4602
|
{
|
4604
|
4603
|
$method = $request->getMethod();
|
4605
|
4604
|
$excludeMethods = $this->getArrayProperty('excludeMethods', 'OPTIONS,GET');
|
|
@@ -4610,7 +4609,7 @@ class AjaxOnlyMiddleware extends Middleware
|
4610
|
4609
|
return $this->responder->error(ErrorCode::ONLY_AJAX_REQUESTS_ALLOWED, $method);
|
4611
|
4610
|
}
|
4612
|
4611
|
}
|
4613
|
|
- return $this->next->handle($request);
|
|
4612
|
+ return $next->handle($request);
|
4614
|
4613
|
}
|
4615
|
4614
|
}
|
4616
|
4615
|
|
|
@@ -4673,7 +4672,7 @@ class AuthorizationMiddleware extends Middleware
|
4673
|
4672
|
}
|
4674
|
4673
|
}
|
4675
|
4674
|
|
4676
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
4675
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
4677
|
4676
|
{
|
4678
|
4677
|
$path = RequestUtils::getPathSegment($request, 1);
|
4679
|
4678
|
$operation = RequestUtils::getOperation($request);
|
|
@@ -4688,7 +4687,7 @@ class AuthorizationMiddleware extends Middleware
|
4688
|
4687
|
VariableStore::set('authorization.tableHandler', $this->getProperty('tableHandler', ''));
|
4689
|
4688
|
VariableStore::set('authorization.columnHandler', $this->getProperty('columnHandler', ''));
|
4690
|
4689
|
}
|
4691
|
|
- return $this->next->handle($request);
|
|
4690
|
+ return $next->handle($request);
|
4692
|
4691
|
}
|
4693
|
4692
|
}
|
4694
|
4693
|
|
|
@@ -4761,7 +4760,7 @@ class BasicAuthMiddleware extends Middleware
|
4761
|
4760
|
return base64_decode(strtr($parts[1], '-_', '+/'));
|
4762
|
4761
|
}
|
4763
|
4762
|
|
4764
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
4763
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
4765
|
4764
|
{
|
4766
|
4765
|
if (session_status() == PHP_SESSION_NONE) {
|
4767
|
4766
|
session_start();
|
|
@@ -4791,7 +4790,7 @@ class BasicAuthMiddleware extends Middleware
|
4791
|
4790
|
return $response;
|
4792
|
4791
|
}
|
4793
|
4792
|
}
|
4794
|
|
- return $this->next->handle($request);
|
|
4793
|
+ return $next->handle($request);
|
4795
|
4794
|
}
|
4796
|
4795
|
}
|
4797
|
4796
|
|
|
@@ -4813,7 +4812,7 @@ class CorsMiddleware extends Middleware
|
4813
|
4812
|
return $found;
|
4814
|
4813
|
}
|
4815
|
4814
|
|
4816
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
4815
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
4817
|
4816
|
{
|
4818
|
4817
|
$method = $request->getMethod();
|
4819
|
4818
|
$origin = count($request->getHeader('Origin')) ? $request->getHeader('Origin')[0] : '';
|
|
@@ -4843,7 +4842,7 @@ class CorsMiddleware extends Middleware
|
4843
|
4842
|
$response = $response->withHeader('Access-Control-Expose-Headers', $exposeHeaders);
|
4844
|
4843
|
}
|
4845
|
4844
|
} else {
|
4846
|
|
- $response = $this->next->handle($request);
|
|
4845
|
+ $response = $next->handle($request);
|
4847
|
4846
|
}
|
4848
|
4847
|
if ($origin) {
|
4849
|
4848
|
$allowCredentials = $this->getProperty('allowCredentials', 'true');
|
|
@@ -4868,7 +4867,7 @@ class CustomizationMiddleware extends Middleware
|
4868
|
4867
|
$this->reflection = $reflection;
|
4869
|
4868
|
}
|
4870
|
4869
|
|
4871
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
4870
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
4872
|
4871
|
{
|
4873
|
4872
|
$operation = RequestUtils::getOperation($request);
|
4874
|
4873
|
$tableName = RequestUtils::getPathSegment($request, 2);
|
|
@@ -4878,7 +4877,7 @@ class CustomizationMiddleware extends Middleware
|
4878
|
4877
|
$result = call_user_func($beforeHandler, $operation, $tableName, $request, $environment);
|
4879
|
4878
|
$request = $result ?: $request;
|
4880
|
4879
|
}
|
4881
|
|
- $response = $this->next->handle($request);
|
|
4880
|
+ $response = $next->handle($request);
|
4882
|
4881
|
$afterHandler = $this->getProperty('afterHandler', '');
|
4883
|
4882
|
if ($afterHandler !== '') {
|
4884
|
4883
|
$result = call_user_func($afterHandler, $operation, $tableName, $response, $environment);
|
|
@@ -4917,7 +4916,7 @@ class FirewallMiddleware extends Middleware
|
4917
|
4916
|
return false;
|
4918
|
4917
|
}
|
4919
|
4918
|
|
4920
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
4919
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
4921
|
4920
|
{
|
4922
|
4921
|
$reverseProxy = $this->getProperty('reverseProxy', '');
|
4923
|
4922
|
if ($reverseProxy) {
|
|
@@ -4931,7 +4930,7 @@ class FirewallMiddleware extends Middleware
|
4931
|
4930
|
if (!$this->isIpAllowed($ipAddress, $allowedIpAddresses)) {
|
4932
|
4931
|
$response = $this->responder->error(ErrorCode::TEMPORARY_OR_PERMANENTLY_BLOCKED, '');
|
4933
|
4932
|
} else {
|
4934
|
|
- $response = $this->next->handle($request);
|
|
4933
|
+ $response = $next->handle($request);
|
4935
|
4934
|
}
|
4936
|
4935
|
return $response;
|
4937
|
4936
|
}
|
|
@@ -4967,7 +4966,7 @@ class IpAddressMiddleware extends Middleware
|
4967
|
4966
|
return (object) $context;
|
4968
|
4967
|
}
|
4969
|
4968
|
|
4970
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
4969
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
4971
|
4970
|
{
|
4972
|
4971
|
$operation = RequestUtils::getOperation($request);
|
4973
|
4972
|
if (in_array($operation, ['create', 'update', 'increment'])) {
|
|
@@ -4990,7 +4989,7 @@ class IpAddressMiddleware extends Middleware
|
4990
|
4989
|
}
|
4991
|
4990
|
}
|
4992
|
4991
|
}
|
4993
|
|
- return $this->next->handle($request);
|
|
4992
|
+ return $next->handle($request);
|
4994
|
4993
|
}
|
4995
|
4994
|
}
|
4996
|
4995
|
|
|
@@ -5006,7 +5005,7 @@ class JoinLimitsMiddleware extends Middleware
|
5006
|
5005
|
$this->reflection = $reflection;
|
5007
|
5006
|
}
|
5008
|
5007
|
|
5009
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
5008
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
5010
|
5009
|
{
|
5011
|
5010
|
$operation = RequestUtils::getOperation($request);
|
5012
|
5011
|
$params = RequestUtils::getParams($request);
|
|
@@ -5035,7 +5034,7 @@ class JoinLimitsMiddleware extends Middleware
|
5035
|
5034
|
$request = RequestUtils::setParams($request, $params);
|
5036
|
5035
|
VariableStore::set("joinLimits.maxRecords", $maxRecords);
|
5037
|
5036
|
}
|
5038
|
|
- return $this->next->handle($request);
|
|
5037
|
+ return $next->handle($request);
|
5039
|
5038
|
}
|
5040
|
5039
|
}
|
5041
|
5040
|
|
|
@@ -5154,7 +5153,7 @@ class JwtAuthMiddleware extends Middleware
|
5154
|
5153
|
return $parts[1];
|
5155
|
5154
|
}
|
5156
|
5155
|
|
5157
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
5156
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
5158
|
5157
|
{
|
5159
|
5158
|
if (session_status() == PHP_SESSION_NONE) {
|
5160
|
5159
|
session_start();
|
|
@@ -5176,7 +5175,7 @@ class JwtAuthMiddleware extends Middleware
|
5176
|
5175
|
return $this->responder->error(ErrorCode::AUTHENTICATION_REQUIRED, '');
|
5177
|
5176
|
}
|
5178
|
5177
|
}
|
5179
|
|
- return $this->next->handle($request);
|
|
5178
|
+ return $next->handle($request);
|
5180
|
5179
|
}
|
5181
|
5180
|
}
|
5182
|
5181
|
|
|
@@ -5237,7 +5236,7 @@ class MultiTenancyMiddleware extends Middleware
|
5237
|
5236
|
return $request->withParsedBody($multi ? $records : $records[0]);
|
5238
|
5237
|
}
|
5239
|
5238
|
|
5240
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
5239
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
5241
|
5240
|
{
|
5242
|
5241
|
$handler = $this->getProperty('handler', '');
|
5243
|
5242
|
if ($handler !== '') {
|
|
@@ -5260,7 +5259,7 @@ class MultiTenancyMiddleware extends Middleware
|
5260
|
5259
|
}
|
5261
|
5260
|
}
|
5262
|
5261
|
}
|
5263
|
|
- return $this->next->handle($request);
|
|
5262
|
+ return $next->handle($request);
|
5264
|
5263
|
}
|
5265
|
5264
|
}
|
5266
|
5265
|
|
|
@@ -5276,7 +5275,7 @@ class PageLimitsMiddleware extends Middleware
|
5276
|
5275
|
$this->reflection = $reflection;
|
5277
|
5276
|
}
|
5278
|
5277
|
|
5279
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
5278
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
5280
|
5279
|
{
|
5281
|
5280
|
$operation = RequestUtils::getOperation($request);
|
5282
|
5281
|
if ($operation == 'list') {
|
|
@@ -5300,7 +5299,7 @@ class PageLimitsMiddleware extends Middleware
|
5300
|
5299
|
}
|
5301
|
5300
|
$request = RequestUtils::setParams($request, $params);
|
5302
|
5301
|
}
|
5303
|
|
- return $this->next->handle($request);
|
|
5302
|
+ return $next->handle($request);
|
5304
|
5303
|
}
|
5305
|
5304
|
}
|
5306
|
5305
|
|
|
@@ -5329,7 +5328,7 @@ class SanitationMiddleware extends Middleware
|
5329
|
5328
|
return (object) $context;
|
5330
|
5329
|
}
|
5331
|
5330
|
|
5332
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
5331
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
5333
|
5332
|
{
|
5334
|
5333
|
$operation = RequestUtils::getOperation($request);
|
5335
|
5334
|
if (in_array($operation, ['create', 'update', 'increment'])) {
|
|
@@ -5352,7 +5351,7 @@ class SanitationMiddleware extends Middleware
|
5352
|
5351
|
}
|
5353
|
5352
|
}
|
5354
|
5353
|
}
|
5355
|
|
- return $this->next->handle($request);
|
|
5354
|
+ return $next->handle($request);
|
5356
|
5355
|
}
|
5357
|
5356
|
}
|
5358
|
5357
|
|
|
@@ -5388,7 +5387,7 @@ class ValidationMiddleware extends Middleware
|
5388
|
5387
|
return null;
|
5389
|
5388
|
}
|
5390
|
5389
|
|
5391
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
5390
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
5392
|
5391
|
{
|
5393
|
5392
|
$operation = RequestUtils::getOperation($request);
|
5394
|
5393
|
if (in_array($operation, ['create', 'update', 'increment'])) {
|
|
@@ -5416,7 +5415,7 @@ class ValidationMiddleware extends Middleware
|
5416
|
5415
|
}
|
5417
|
5416
|
}
|
5418
|
5417
|
}
|
5419
|
|
- return $this->next->handle($request);
|
|
5418
|
+ return $next->handle($request);
|
5420
|
5419
|
}
|
5421
|
5420
|
}
|
5422
|
5421
|
|
|
@@ -5439,7 +5438,7 @@ class XsrfMiddleware extends Middleware
|
5439
|
5438
|
return $token;
|
5440
|
5439
|
}
|
5441
|
5440
|
|
5442
|
|
- public function handle(ServerRequestInterface $request): ResponseInterface
|
|
5441
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
|
5443
|
5442
|
{
|
5444
|
5443
|
$token = $this->getToken();
|
5445
|
5444
|
$method = $request->getMethod();
|
|
@@ -5450,7 +5449,7 @@ class XsrfMiddleware extends Middleware
|
5450
|
5449
|
return $this->responder->error(ErrorCode::BAD_OR_MISSING_XSRF_TOKEN, '');
|
5451
|
5450
|
}
|
5452
|
5451
|
}
|
5453
|
|
- return $this->next->handle($request);
|
|
5452
|
+ return $next->handle($request);
|
5454
|
5453
|
}
|
5455
|
5454
|
}
|
5456
|
5455
|
|