response.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /*
  3. * This file is part of the Jiannei/lumen-api-starter.
  4. *
  5. * (c) Jiannei <longjian.huang@foxmail.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. use App\Repositories\Enums\ResponseCodeEnum;
  11. return [
  12. /*
  13. |--------------------------------------------------------------------------
  14. | Set the http status code when the response fails
  15. |--------------------------------------------------------------------------
  16. |
  17. | the reference options are false, 200, 500
  18. |
  19. | false, stricter http status codes such as 404, 401, 403, 500, etc. will be returned
  20. | 200, All failed responses will also return a 200 status code
  21. | 500, All failed responses return a 500 status code
  22. */
  23. 'error_code' => false,
  24. // Set the http status code returned when the form validation fails.
  25. // When the error_code is set to 200 or 500, it will not work
  26. 'validation_error_code' => ResponseCodeEnum::CLIENT_VALIDATION_ERROR,
  27. // Set the structure of the paging data return,the following structure will be returned by default,
  28. // You can modify the name of the inner data field through the following configuration items, such as rows or list
  29. //{
  30. // "status": "success",
  31. // "code": 200,
  32. // "message": "Success.",
  33. // "data": {
  34. // "data": [
  35. // // ...
  36. // ],
  37. // "meta": {
  38. // // ...
  39. // }
  40. // },
  41. // "error": {}
  42. //}
  43. 'format' => [
  44. 'paginated_resource' => [
  45. 'data_field' => 'list',
  46. ],
  47. ],
  48. // You can use enumerations to define the code when the response is returned,
  49. // and set the response message according to the locale
  50. //
  51. // The following two enumeration packages are good choices
  52. //
  53. // https://github.com/Jiannei/laravel-enum
  54. // https://github.com/BenSampo/laravel-enum
  55. 'enum' => ResponseCodeEnum::class,
  56. ];