示例#1
0
        case "/api/getSupNRPEPlugin":
        case "/api/getRouterVM":
        case "/api/getNagiosPlugin":
        case "/api/getNagiosPlugins":
            require_once BASE_PATH . "/routes/apiv1.route.php";
            break;
        default:
            break;
    }
});
$app->contentType('application/json');
$app->notFound(function () use($app) {
    $request = $app->request();
    $headers = $request->headers();
    $uri = $request->getResourceUri();
    $apiResponse = new APIViewData(1, false, "The page you are looking for could not be found. Check the address to ensure your URL is spelled correctly...");
    $apiResponse->setExtraResponseData('url', $request->headers('X_FORWARDED_PROTO') . '://' . $request->headers('HOST') . $request->getRootUri() . $request->getResourceUri());
    $app->halt('404', $apiResponse->returnJson());
});
// Initial Dummy Routes
// Leave the / on the end of /sapi/ due to rewrite engine, otherwise requests to /sapi break
$app->get('/sapi/', function () use($app) {
    $msg = "Welcome to /sapi/ ... What can we help you with?";
    $apiResponse = new APIViewData(0, false, $msg);
    $apiResponse->printJson();
})->name('saigon-api');
$app->get('/sapi/version', function () use($app) {
    $apiResponse = new APIViewData(0, false, API_VERSION . " (alpha/beta/charlie/delta/echo/use at your own risk)");
    $apiResponse->printJson();
})->name('saigon-api-version');
$app->run();