diff --git a/html/api_v0.php b/html/api_v0.php index d42a1f820c..613deae1c5 100644 --- a/html/api_v0.php +++ b/html/api_v0.php @@ -40,6 +40,7 @@ $app->group('/api', function() use ($app) { $app->post('/devices', 'authToken', 'add_device')->name('add_device');//api/v0/devices (json data needs to be passed) $app->delete('/devices/:hostname', 'authToken', 'del_device')->name('del_device');//api/v0/devices (json data needs to be passed) }); + $app->get('/v0', 'authToken', 'show_endpoints');//api/v0 }); $app->run(); diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index 56fdb6722d..76b03170d8 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -479,3 +479,16 @@ function get_vlans() { $app->response->headers->set('Content-Type', 'application/json'); echo _json_encode($output); } + +function show_endpoints() { + global $config; + $app = \Slim\Slim::getInstance(); + $routes = $app->router()->getNamedRoutes(); + $output = array(); + foreach($routes as $route) { + $output[$route->getName()] = $config['base_url'].$route->getPattern(); + } + $app->response->setStatus('200'); + $app->response->headers->set('Content-Type', 'application/json'); + echo _json_encode($output); +}