api.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Application Routes
  5. |--------------------------------------------------------------------------
  6. |
  7. | Here is where you can register all of the routes for an application.
  8. | It is a breeze. Simply tell Lumen the URIs it should respond to
  9. | and give it the Closure to call when that URI is requested.
  10. |
  11. */
  12. $api = app('Dingo\Api\Routing\Router');
  13. $api->version('v1', [
  14. 'namespace' => 'App\Http\Controllers',
  15. ], function ($api) {
  16. //登录
  17. $api->post('login', 'AuthController@authenticate');
  18. $api->group(['middleware' => 'auth:api'], function ($api) {
  19. //注册
  20. $api->post('reg', 'AuthController@register');
  21. //登出
  22. $api->post('logout', 'AuthController@logout');
  23. //刷新身份令牌
  24. $api->post('refresh', 'AuthController@refresh');
  25. });
  26. //测试
  27. $api->get('test', 'TestController@index');
  28. //配置
  29. $api->get('config', 'ConfigController@index');
  30. $api->group(['namespace' => 'Post'], function ($api) {
  31. //发布内容
  32. $api->post('post', 'PostController@create');
  33. //内容列表
  34. $api->get('post', 'PostController@index');
  35. });
  36. $api->group(['middleware' => 'jwt.chxq_auth'], function ($api) {
  37. });
  38. //行为
  39. $api->group(['namespace' => 'Behavior'], function ($api) {
  40. //行为列表
  41. $api->get('behavior/list', 'BehaviorController@index');
  42. });
  43. });