ApiController.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Controllers\Api;
  3. use PH7\JustHttp\StatusCode;
  4. class ApiController
  5. {
  6. /*
  7. * Muestra la presentación de la API.
  8. */
  9. public function index($req, $res)
  10. {
  11. $res->json([
  12. 'data' => [
  13. 'name' => 'tinynote API RESTful',
  14. 'description' => 'A simple markdown note taking application with encryption support built in PHP',
  15. 'documentation' => 'https://ricardogj08.github.io/tinynote/',
  16. 'repository' => 'https://notabug.org/ricardogj08/tinynote/',
  17. 'license' => 'AGPL-3.0-or-later',
  18. 'author' => [
  19. 'fullname' => 'Ricardo García Jiménez',
  20. 'email' => 'ricardogj08@riseup.net',
  21. 'homepage' => 'https://ricardogj08.github.io/blog/',
  22. 'role' => 'Backend developer'
  23. ]
  24. ]
  25. ]);
  26. }
  27. /*
  28. * Error 404 de la API.
  29. */
  30. public function error404($req, $res)
  31. {
  32. $res->status(StatusCode::NOT_FOUND)->json([
  33. 'error' => 'Endpoint not found'
  34. ]);
  35. }
  36. }