1
|
|
|
<?php |
2
|
|
|
namespace LunixREST\Server; |
3
|
|
|
|
4
|
|
|
use LunixREST\Server\AccessControl\AccessControl; |
5
|
|
|
use LunixREST\Server\APIRequest\APIRequest; |
6
|
|
|
use LunixREST\Server\APIResponse\APIResponse; |
7
|
|
|
use LunixREST\Server\Exceptions\UnableToHandleRequestException; |
8
|
|
|
use LunixREST\Server\ResponseFactory\Exceptions\NotAcceptableResponseTypeException; |
9
|
|
|
use LunixREST\Server\ResponseFactory\Exceptions\UnableToCreateAPIResponseException; |
10
|
|
|
use LunixREST\Server\ResponseFactory\ResponseFactory; |
11
|
|
|
use LunixREST\Server\Router\Endpoint\Exceptions\ElementConflictException; |
12
|
|
|
use LunixREST\Server\Router\Endpoint\Exceptions\ElementNotFoundException; |
13
|
|
|
use LunixREST\Server\Router\Endpoint\Exceptions\EndpointExecutionException; |
14
|
|
|
use LunixREST\Server\Router\Endpoint\Exceptions\InvalidRequestException; |
15
|
|
|
use LunixREST\Server\Router\Endpoint\Exceptions\UnsupportedMethodException; |
16
|
|
|
use LunixREST\Server\Router\EndpointFactory\Exceptions\UnableToCreateEndpointException; |
17
|
|
|
use LunixREST\Server\Router\Exceptions\MethodNotFoundException; |
18
|
|
|
use LunixREST\Server\Router\Exceptions\UnableToRouteRequestException; |
19
|
|
|
use LunixREST\Server\Router\GenericRouter; |
20
|
|
|
use LunixREST\Server\Throttle\Throttle; |
21
|
|
|
use LunixREST\Server\Exceptions\AccessDeniedException; |
22
|
|
|
use LunixREST\Server\Exceptions\InvalidAPIKeyException; |
23
|
|
|
use LunixREST\Server\Exceptions\ThrottleLimitExceededException; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* A GenericServer that requires a GenericRouter to be used as it's router. Helpful to define exceptions to handle with this |
27
|
|
|
* combination. |
28
|
|
|
* Class GenericRouterGenericServer |
29
|
|
|
* @package LunixREST\Server |
30
|
|
|
*/ |
31
|
|
|
class GenericRouterGenericServer extends GenericServer |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* GenericRouterGenericServer constructor. |
35
|
|
|
* @param AccessControl $accessControl |
36
|
|
|
* @param Throttle $throttle |
37
|
|
|
* @param ResponseFactory $responseFactory |
38
|
|
|
* @param GenericRouter $router |
39
|
|
|
*/ |
40
|
|
|
public function __construct( |
41
|
|
|
AccessControl $accessControl, |
42
|
|
|
Throttle $throttle, |
43
|
|
|
ResponseFactory $responseFactory, |
44
|
|
|
GenericRouter $router |
45
|
|
|
) { |
46
|
|
|
parent::__construct($accessControl, $throttle, $responseFactory, $router); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param APIRequest $request |
52
|
|
|
* @return APIResponse |
53
|
|
|
* @throws UnableToHandleRequestException |
54
|
|
|
* @throws InvalidAPIKeyException |
55
|
|
|
* @throws ThrottleLimitExceededException |
56
|
|
|
* @throws NotAcceptableResponseTypeException |
57
|
|
|
* @throws AccessDeniedException |
58
|
|
|
* @throws UnableToRouteRequestException |
59
|
|
|
* @throws UnableToCreateEndpointException |
60
|
|
|
* @throws MethodNotFoundException |
61
|
|
|
* @throws EndpointExecutionException |
62
|
|
|
* @throws UnsupportedMethodException |
63
|
|
|
* @throws ElementNotFoundException |
64
|
|
|
* @throws InvalidRequestException |
65
|
|
|
* @throws ElementConflictException |
66
|
|
|
* @throws UnableToCreateAPIResponseException |
67
|
|
|
*/ |
68
|
|
|
public function handleRequest(APIRequest $request): APIResponse |
69
|
|
|
{ |
70
|
|
|
return parent::handleRequest($request); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|