index.html 1.2 KB

123456789101112131415161718192021222324252627
  1. Place all custom route files here in this directory....
  2. Name file something anything you like...
  3. <pre>
  4. &lt;?php
  5. /*
  6. * The first thing you need to edit it the <code>get</code> part - options are get/post/delete/put/options
  7. * The second thing you need to edit is the </code>/something</code>
  8. * This will be the endpoints name and will be accessible from: http://organizr/api/v2/custom/something
  9. */
  10. $app->get('/custom/something', function ($request, $response, $args) {
  11. // Let's define the Organizr Class to the $Organizr variable
  12. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  13. // Now let's set auth on our function, 1 is for co-admin and upto 999 is for Guest
  14. if ($Organizr->qualifyRequest(1, true)) {
  15. // Let's assign the api response with our function that holds our data...
  16. $GLOBALS['api']['response']['data'] = $Organizr->getAllUsers();
  17. }
  18. // You do not need to change anything else below this line
  19. $response->getBody()->write(jsonE($GLOBALS['api']));
  20. return $response
  21. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  22. ->withStatus($GLOBALS['responseCode']);
  23. });
  24. </pre>