@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param string $extension |
58 | 58 | * @param string $instance |
59 | 59 | */ |
60 | - public function __construct($method, array $headers, array $data, $ip, $version, $apiKey, $endpoint, $extension, $instance = null){ |
|
60 | + public function __construct($method, array $headers, array $data, $ip, $version, $apiKey, $endpoint, $extension, $instance = null) { |
|
61 | 61 | $this->method = strtolower($method); |
62 | 62 | $this->headers = $headers; |
63 | 63 | $this->data = $data; |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | * @return Request |
151 | 151 | * @throws InvalidRequestFormatException |
152 | 152 | */ |
153 | - public static function createFromURL($method, array $headers, array $data, $ip, $url){ |
|
153 | + public static function createFromURL($method, array $headers, array $data, $ip, $url) { |
|
154 | 154 | $splitURL = explode('/', trim($url, '/')); |
155 | - if(count($splitURL) < 3){ |
|
155 | + if (count($splitURL) < 3) { |
|
156 | 156 | throw new InvalidRequestFormatException(); |
157 | 157 | } |
158 | 158 | //Find endpoint |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | $instance = null; |
167 | 167 | |
168 | - if(count($splitURL) == 4){ |
|
168 | + if (count($splitURL) == 4) { |
|
169 | 169 | $instance = implode('.', $splitExtension); |
170 | 170 | } else { |
171 | 171 | $endpoint = implode('.', $splitExtension); |
@@ -9,27 +9,27 @@ |
||
9 | 9 | $router = new \LunixREST\Router\Router($accessControl, $throttle, $formatsConfig, "HelloWorld"); |
10 | 10 | |
11 | 11 | try { |
12 | - $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
12 | + $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
13 | 13 | |
14 | - try { |
|
15 | - echo $router->handle($request); |
|
16 | - } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
17 | - header('400 Bad Request', true, 400); |
|
18 | - } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
19 | - header('404 Not Found', true, 404); |
|
20 | - } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
21 | - header('404 Not Found', true, 404); |
|
22 | - } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
23 | - header('403 Access Denied', true, 403); |
|
24 | - } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
25 | - header('429 Too Many Requests', true, 429); |
|
26 | - } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
27 | - header('500 Internal Server Error', true, 500); |
|
28 | - } catch(Exception $e){ |
|
29 | - header('500 Internal Server Error', true, 500); |
|
30 | - } |
|
14 | + try { |
|
15 | + echo $router->handle($request); |
|
16 | + } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
17 | + header('400 Bad Request', true, 400); |
|
18 | + } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
19 | + header('404 Not Found', true, 404); |
|
20 | + } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
21 | + header('404 Not Found', true, 404); |
|
22 | + } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
23 | + header('403 Access Denied', true, 403); |
|
24 | + } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
25 | + header('429 Too Many Requests', true, 429); |
|
26 | + } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
27 | + header('500 Internal Server Error', true, 500); |
|
28 | + } catch(Exception $e){ |
|
29 | + header('500 Internal Server Error', true, 500); |
|
30 | + } |
|
31 | 31 | } catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){ |
32 | - header('400 Bad Request', true, 400); |
|
32 | + header('400 Bad Request', true, 400); |
|
33 | 33 | } catch(Exception $e){ |
34 | - header('500 Internal Server Error', true, 500); |
|
34 | + header('500 Internal Server Error', true, 500); |
|
35 | 35 | } |
@@ -9,27 +9,27 @@ |
||
9 | 9 | $router = new \LunixREST\Router\Router($accessControl, $throttle, $formatsConfig, "HelloWorld"); |
10 | 10 | |
11 | 11 | try { |
12 | - $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
12 | + $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json"); // \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
13 | 13 | |
14 | 14 | try { |
15 | 15 | echo $router->handle($request); |
16 | - } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
16 | + } catch (\LunixREST\Exceptions\InvalidAPIKeyException $e) { |
|
17 | 17 | header('400 Bad Request', true, 400); |
18 | - } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
18 | + } catch (\LunixREST\Exceptions\UnknownEndpointException $e) { |
|
19 | 19 | header('404 Not Found', true, 404); |
20 | - } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
20 | + } catch (\LunixREST\Exceptions\UnknownResponseFormatException $e) { |
|
21 | 21 | header('404 Not Found', true, 404); |
22 | - } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
22 | + } catch (\LunixREST\Exceptions\AccessDeniedException $e) { |
|
23 | 23 | header('403 Access Denied', true, 403); |
24 | - } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
24 | + } catch (\LunixREST\Exceptions\ThrottleLimitExceededException $e) { |
|
25 | 25 | header('429 Too Many Requests', true, 429); |
26 | - } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
26 | + } catch (\LunixREST\Exceptions\InvalidResponseFormatException $e) { |
|
27 | 27 | header('500 Internal Server Error', true, 500); |
28 | - } catch(Exception $e){ |
|
28 | + } catch (Exception $e) { |
|
29 | 29 | header('500 Internal Server Error', true, 500); |
30 | 30 | } |
31 | -} catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){ |
|
31 | +} catch (\LunixREST\Exceptions\InvalidRequestFormatException $e) { |
|
32 | 32 | header('400 Bad Request', true, 400); |
33 | -} catch(Exception $e){ |
|
33 | +} catch (Exception $e) { |
|
34 | 34 | header('500 Internal Server Error', true, 500); |
35 | 35 | } |
@@ -10,29 +10,29 @@ |
||
10 | 10 | $router = new \LunixREST\Router\Router($accessControl, $throttle, $formatsConfig, "GeoPhone"); |
11 | 11 | |
12 | 12 | try { |
13 | - $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1/123456/phonenumbers/6517855237.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
13 | + $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1/123456/phonenumbers/6517855237.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
14 | 14 | |
15 | - try { |
|
16 | - echo $router->handle($request); |
|
17 | - } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
18 | - header('400 Bad Request', true, 400); |
|
19 | - } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
20 | - header('404 Not Found', true, 404); |
|
21 | - } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
22 | - header('404 Not Found', true, 404); |
|
23 | - } catch(\LunixREST\Exceptions\InstanceNotFoundException $e){ |
|
24 | - header('404 Not Found', true, 404); |
|
25 | - } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
26 | - header('403 Access Denied', true, 403); |
|
27 | - } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
28 | - header('429 Too Many Requests', true, 429); |
|
29 | - } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
30 | - header('500 Internal Server Error', true, 500); |
|
31 | - } catch(Exception $e){ |
|
32 | - header('500 Internal Server Error', true, 500); |
|
33 | - } |
|
15 | + try { |
|
16 | + echo $router->handle($request); |
|
17 | + } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
18 | + header('400 Bad Request', true, 400); |
|
19 | + } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
20 | + header('404 Not Found', true, 404); |
|
21 | + } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
22 | + header('404 Not Found', true, 404); |
|
23 | + } catch(\LunixREST\Exceptions\InstanceNotFoundException $e){ |
|
24 | + header('404 Not Found', true, 404); |
|
25 | + } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
26 | + header('403 Access Denied', true, 403); |
|
27 | + } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
28 | + header('429 Too Many Requests', true, 429); |
|
29 | + } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
30 | + header('500 Internal Server Error', true, 500); |
|
31 | + } catch(Exception $e){ |
|
32 | + header('500 Internal Server Error', true, 500); |
|
33 | + } |
|
34 | 34 | } catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){ |
35 | - header('400 Bad Request', 400); |
|
35 | + header('400 Bad Request', 400); |
|
36 | 36 | } catch(Exception $e){ |
37 | - header('500 Internal Server Error', true, 500); |
|
37 | + header('500 Internal Server Error', true, 500); |
|
38 | 38 | } |
@@ -10,29 +10,29 @@ |
||
10 | 10 | $router = new \LunixREST\Router\Router($accessControl, $throttle, $formatsConfig, "GeoPhone"); |
11 | 11 | |
12 | 12 | try { |
13 | - $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1/123456/phonenumbers/6517855237.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
13 | + $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1/123456/phonenumbers/6517855237.json"); // \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
14 | 14 | |
15 | 15 | try { |
16 | 16 | echo $router->handle($request); |
17 | - } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
17 | + } catch (\LunixREST\Exceptions\InvalidAPIKeyException $e) { |
|
18 | 18 | header('400 Bad Request', true, 400); |
19 | - } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
19 | + } catch (\LunixREST\Exceptions\UnknownEndpointException $e) { |
|
20 | 20 | header('404 Not Found', true, 404); |
21 | - } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
21 | + } catch (\LunixREST\Exceptions\UnknownResponseFormatException $e) { |
|
22 | 22 | header('404 Not Found', true, 404); |
23 | - } catch(\LunixREST\Exceptions\InstanceNotFoundException $e){ |
|
23 | + } catch (\LunixREST\Exceptions\InstanceNotFoundException $e) { |
|
24 | 24 | header('404 Not Found', true, 404); |
25 | - } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
25 | + } catch (\LunixREST\Exceptions\AccessDeniedException $e) { |
|
26 | 26 | header('403 Access Denied', true, 403); |
27 | - } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
27 | + } catch (\LunixREST\Exceptions\ThrottleLimitExceededException $e) { |
|
28 | 28 | header('429 Too Many Requests', true, 429); |
29 | - } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
29 | + } catch (\LunixREST\Exceptions\InvalidResponseFormatException $e) { |
|
30 | 30 | header('500 Internal Server Error', true, 500); |
31 | - } catch(Exception $e){ |
|
31 | + } catch (Exception $e) { |
|
32 | 32 | header('500 Internal Server Error', true, 500); |
33 | 33 | } |
34 | -} catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){ |
|
34 | +} catch (\LunixREST\Exceptions\InvalidRequestFormatException $e) { |
|
35 | 35 | header('400 Bad Request', 400); |
36 | -} catch(Exception $e){ |
|
36 | +} catch (Exception $e) { |
|
37 | 37 | header('500 Internal Server Error', true, 500); |
38 | 38 | } |