-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
82 lines (66 loc) · 2.87 KB
/
index.php
File metadata and controls
82 lines (66 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
use app\controller\Api as ApiController;
use app\library\config as Config;
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/src/constants.php';
$settings = require __DIR__ . '/src/settings.php';
$app = new \Slim\App($settings);
$app->post('/builds/update', function (Request $request, Response $response) use ($app) {
try {
$params = $request->getQueryParams();
$headers = apache_request_headers();
/* Update Build Status */
$api = new ApiController($this);
$update = $api->updateBuildStatus($headers, $params, $this);
$response_status = $update['status'];
$msg = $update['message'];
/* Generate Response */
$data = array('status' => $response_status, 'message' => $msg);
$response = $response->withHeader('Content-type', 'application/json');
$response = $response->withAddedHeader('Allow', 'POST');
$newResponse = $response->withJson($data);
return $newResponse;
/* Generate Response */
} catch (Exception $e) {
return json_encode(array("status" => "error", "message" => $e->getMessage()));
}
});
$app->get('/certificate/log/expiration', function (Request $request, Response $response) use ($app) {
try {
$params = $request->getQueryParams();
$headers = apache_request_headers();
$api = new ApiController($this);
$check = $api->checkCertificateLogExpiration($headers, $this);
$response_status = $check['status'];
$msg = $check['message'];
$data = array('status' => $response_status, 'message' => $msg);
$newResponse = $response->withJson($data);
if (empty($this->access_key)) {
$msg = ACCESS_KEY_NOT_SET;
$response_status = FAILURE_STATUS;
return $response = array("status" => $response_status, "message" => $msg);
}
} catch (Exception $e) {
return json_encode(array("status" => "error", "message" => $e->getMessage()));
}
});
$app->get('/provision/log/expiration', function (Request $request, Response $response) use ($app) {
try {
$params = $request->getQueryParams();
$headers = apache_request_headers();
$api = new ApiController($this);
$check = $api->checkProvisioningLogExpiration($headers, $this);
$response_status = $check['status'];
$msg = $check['message'];
$data = array('status' => $response_status, 'message' => $msg);
$response = $response->withHeader('Content-type', 'application/json');
$response = $response->withAddedHeader('Allow', 'GET');
$newResponse = $response->withJson($data);
} catch (Exception $e) {
return json_encode(array("status" => "error", "message" => $e->getMessage()));
}
});
$app->run();
?>