1
|
<?php
|
2
|
|
3
|
/*
|
4
|
|--------------------------------------------------------------------------
|
5
|
| Application Routes
|
6
|
|--------------------------------------------------------------------------
|
7
|
|
|
8
|
| Here is where you can register all of the routes for an application.
|
9
|
| It is a breeze. Simply tell Lumen the URIs it should respond to
|
10
|
| and give it the Closure to call when that URI is requested.
|
11
|
|
|
12
|
*/
|
13
|
|
14
|
$apiUrlRoot='/api/v1/';
|
15
|
$corsMiddle = 'cors';
|
16
|
$jwtMiddle = 'jwtauth';
|
17
|
|
18
|
/**
|
19
|
* Welcome endpoint.
|
20
|
*/
|
21
|
$app->get('/', function () {
|
22
|
return 'Welcome.';
|
23
|
});
|
24
|
|
25
|
/**
|
26
|
* Vrati seznam mericich zarizeni.
|
27
|
*/
|
28
|
$app->get($apiUrlRoot.'devices', [
|
29
|
'middleware' => [$corsMiddle, $jwtMiddle],
|
30
|
'uses' => 'DeviceController@getDevice'
|
31
|
]);
|
32
|
|
33
|
|
34
|
/**
|
35
|
* Vrati zaznamy o doprave za casovy usek pro dane zarizeni.
|
36
|
*/
|
37
|
$app->get($apiUrlRoot.'devices/{id}', [
|
38
|
'middleware' => [$corsMiddle, $jwtMiddle],
|
39
|
'uses' => 'DeviceController@getDeviceByIdWithTraffic'
|
40
|
]);
|
41
|
|
42
|
$app->get($apiUrlRoot.'devices/{id}/csv', [
|
43
|
'middleware' => $jwtMiddle,
|
44
|
'uses' => 'DeviceController@getDeviceByIdAsCsv'
|
45
|
]);
|
46
|
|
47
|
/**
|
48
|
* Vrati prumery dopravy pro danze zarizeni za casovy usek.
|
49
|
*/
|
50
|
$app->get($apiUrlRoot.'devices/{id}/time-period', [
|
51
|
'middleware' => [$corsMiddle, $jwtMiddle],
|
52
|
'uses' => 'DeviceController@getTrafficAverageByDevice'
|
53
|
]);
|
54
|
|
55
|
/**
|
56
|
* Vrati prumery dopravy pro danze zarizeni za casovy usek jako csv.
|
57
|
*/
|
58
|
$app->get($apiUrlRoot.'devices/{id}/time-period/csv', [
|
59
|
'middleware' => $jwtMiddle,
|
60
|
'uses' => 'DeviceController@getTrafficAverageByDeviceCsv'
|
61
|
]);
|
62
|
|
63
|
|
64
|
/**
|
65
|
* Vrati denni prumery podle typu vozidla.
|
66
|
*/
|
67
|
$app->get($apiUrlRoot.'devices/{id}/day-period', [
|
68
|
'middleware' => [$corsMiddle, $jwtMiddle],
|
69
|
'uses' => 'DeviceController@getTrafficDayAverage'
|
70
|
]);
|
71
|
|
72
|
/**
|
73
|
* Vrati denni prumery podle typu vozidla jako csv soubor.
|
74
|
*/
|
75
|
$app->get($apiUrlRoot.'devices/{id}/day-period/csv', [
|
76
|
'middleware' => $jwtMiddle,
|
77
|
'uses' => 'DeviceController@getTrafficDayAverageCsv'
|
78
|
]);
|
79
|
|
80
|
/**
|
81
|
* Vrati vsechny typy aut.
|
82
|
*/
|
83
|
$app->get($apiUrlRoot.'vehicles', [
|
84
|
'middleware' => [$corsMiddle, $jwtMiddle],
|
85
|
'uses' => 'VehicleController@getAll'
|
86
|
]);
|
87
|
|
88
|
/**
|
89
|
* Vrati vsechna mesta.
|
90
|
*/
|
91
|
$app->get($apiUrlRoot.'cities', [
|
92
|
'middleware' => [$corsMiddle, $jwtMiddle],
|
93
|
'uses' => 'LocationController@getCities'
|
94
|
]);
|
95
|
|
96
|
/**
|
97
|
* Vygeneruje novy JWT s omezenou platnosti.
|
98
|
*/
|
99
|
$app->get($apiUrlRoot.'token', 'TokenController@generateToken');
|
100
|
|
101
|
|
102
|
|
103
|
// testovani
|
104
|
$app->get($apiUrlRoot.'header', 'DeviceController@headerTest');
|