|
1
|
|
|
<?php |
|
2
|
|
|
// Add routes here |
|
3
|
|
|
// Variables available : |
|
4
|
|
|
// - $container |
|
5
|
|
|
// - $app |
|
6
|
|
|
|
|
7
|
|
|
use App\App; |
|
8
|
|
|
use App\Controller\ProjectController; |
|
9
|
|
|
use App\Controller\Project\ApiController; |
|
10
|
|
|
use App\Controller\Project\SettingsController; |
|
11
|
|
|
use App\Controller\UserController; |
|
12
|
|
|
use App\Facades\Router; |
|
13
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
14
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
15
|
|
|
|
|
16
|
|
|
$app->get('/', function(ServerRequestInterface $request, ResponseInterface $response) { |
|
17
|
|
|
return $response->withRedirect( |
|
|
|
|
|
|
18
|
|
|
Router::pathFor('project.index') |
|
19
|
|
|
); |
|
20
|
|
|
}); |
|
21
|
|
|
|
|
22
|
|
|
$app->group('/projects', function(App $app) { |
|
23
|
|
|
|
|
24
|
|
|
// General |
|
25
|
|
|
$app->get('', ProjectController::class . ':index') |
|
26
|
|
|
->setName('project.index'); |
|
27
|
|
|
$app->map(['GET', 'POST'], '/add', ProjectController::class . ':add') |
|
28
|
|
|
->setName('project.add'); |
|
29
|
|
|
|
|
30
|
|
|
// Project |
|
31
|
|
|
$app->map(['GET'], '/{key}/prepare-deploy', ProjectController::class . ':prepareDeploy') |
|
32
|
|
|
->setName('project.prepare-deploy'); |
|
33
|
|
|
$app->map(['POST'], '/{key}/deploy', ProjectController::class . ':deploy') |
|
34
|
|
|
->setName('project.deploy'); |
|
35
|
|
|
$app->map(['GET', 'POST'], '/{key}/deploy/{deployment}', ProjectController::class . ':redeploy') |
|
36
|
|
|
->setName('project.redeploy'); |
|
37
|
|
|
$app->map(['GET', 'POST'], '/{key}', ProjectController::class . ':view') |
|
38
|
|
|
->setName('project.view'); |
|
39
|
|
|
|
|
40
|
|
|
// Settings |
|
41
|
|
|
$app->map(['GET', 'POST'], '/{key}/edit', SettingsController::class . ':edit') |
|
42
|
|
|
->setName('project.edit'); |
|
43
|
|
|
$app->map(['GET', 'POST'], '/{key}/webhooks', SettingsController::class . ':webhooks') |
|
44
|
|
|
->setName('project.webhooks'); |
|
45
|
|
|
|
|
46
|
|
|
}); |
|
47
|
|
|
|
|
48
|
|
|
$app->group('/api/project', function(App $app) { |
|
49
|
|
|
$app->map(['GET'], '/{key}/events/{number}', ApiController::class . ':events'); |
|
50
|
|
|
}); |
|
51
|
|
|
|
|
52
|
|
|
// Webhook route is outside normal API routing, mainly for obscurity and brevity |
|
53
|
|
|
$app->get('/d/{token}', ApiController::class . ':webhookDeploy') |
|
54
|
|
|
->setName('project.webhook'); |
|
55
|
|
|
|
|
56
|
|
|
$app->group('/user', function(App $app) { |
|
57
|
|
|
$app->map(['GET', 'POST'], '/login', UserController::class . ':login') |
|
58
|
|
|
->setName('user.login'); |
|
59
|
|
|
$app->map(['GET'], '/logout', UserController::class . ':logout') |
|
60
|
|
|
->setName('user.logout'); |
|
61
|
|
|
$app->map(['GET', 'POST'], '/favourite/{project}', UserController::class . ':favourite') |
|
62
|
|
|
->setName('user.favourite'); |
|
63
|
|
|
$app->map(['GET', 'POST'], '/profile', UserController::class . ':profile') |
|
64
|
|
|
->setName('user.profile'); |
|
65
|
|
|
$app->map(['GET', 'POST'], '/security', UserController::class . ':security') |
|
66
|
|
|
->setName('user.security'); |
|
67
|
|
|
}); |
|
68
|
|
|
|