Clean up routes and middleware checking
This commit is contained in:
parent
99a67127c9
commit
4ae8a45ed3
16 changed files with 321 additions and 101 deletions
|
@ -7,15 +7,24 @@ use Illuminate\Routing\Router;
|
|||
class RestRoutes {
|
||||
|
||||
public function map(Router $router) {
|
||||
$router->group(['prefix' => 'api/v1'], function ($server) use ($router) {
|
||||
|
||||
$router->group(['prefix' => 'users'], function ($server) use ($router) {
|
||||
|
||||
$router->get('/', [ 'uses' => 'API\UserController@getAllUsers' ]);
|
||||
$router->get('/{id}/{fields?}', [ 'uses' => 'API\UserController@getUser' ])->where('id', '[0-9]+');
|
||||
$router->group([
|
||||
'prefix' => 'api/v1',
|
||||
'middleware' => [
|
||||
'api'
|
||||
]
|
||||
], function () use ($router) {
|
||||
// Users endpoint for API
|
||||
$router->group(['prefix' => 'users'], function () use ($router) {
|
||||
// Returns all users
|
||||
$router->get('/', [
|
||||
'uses' => 'API\UserController@getAllUsers'
|
||||
]);
|
||||
|
||||
// Return listing of user [with only specified fields]
|
||||
$router->get('/{id}/{fields?}', [
|
||||
'uses' => 'API\UserController@getUser'
|
||||
])->where('id', '[0-9]+');
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue