Conditions | 3 |
Paths | 3 |
Total Lines | 23 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | public function main(ServerRequestInterface $request): ResponseInterface |
||
28 | { |
||
29 | $api = GeneralUtility::_GP('api'); |
||
30 | $apiKey = trim(GeneralUtility::_GP('apiKey')); |
||
|
|||
31 | |||
32 | if (!Api::isValidApiKey($apiKey)) { |
||
33 | header(HttpUtility::HTTP_STATUS_403); |
||
34 | header('Content-Type: application/json; charset=utf-8'); |
||
35 | echo json_encode(['errorMessage' => 'Invalid API key']); |
||
36 | } else { |
||
37 | switch ($api) { |
||
38 | case 'siteHash': |
||
39 | include('SiteHash.php'); |
||
40 | break; |
||
41 | |||
42 | default: |
||
43 | header(HttpUtility::HTTP_STATUS_400); |
||
44 | header('Content-Type: application/json; charset=utf-8'); |
||
45 | echo json_encode(['errorMessage' => 'You must provide an available API method, e.g. siteHash.']); |
||
46 | break; |
||
47 | } |
||
48 | } |
||
49 | return new Response(); |
||
50 | } |
||
52 |