diff --git a/public_html/api/index.php b/public_html/api/index.php index 4ded2b2a627edcaa53e202ee41d17e94d9b2aebb..480820841044b1be54973e0938f61be555d276be 100644 --- a/public_html/api/index.php +++ b/public_html/api/index.php @@ -6,7 +6,7 @@ * GET /api/v1/projects/ * GET /api/v1/project/[ID]/build/[name-of-branch] * POST /api/v1/project/[ID]/build/[name-of-branch] - * get /api/v1/project/[ID]/phases + * GET /api/v1/project/[ID]/phases * * ---------------------------------------------------------------------- * 2020-06-16 v0.9 <axel.hahn@iml.unibe.ch> @@ -22,14 +22,8 @@ $sDirClasses=__DIR__.'/../deployment/classes/'; require_once($sDirClasses.'/project.class.php'); - require_once($sDirClasses.'logger.class.php'); - $aApiItems=array( - 'project', - 'projects', - 'help', - ); $iMaxAge=60; // ---------------------------------------------------------------------- @@ -70,7 +64,7 @@ */ function _done($Data){ echo is_array($Data) - ? json_encode($Data, 1, JSON_PRETTY_PRINT) + ? json_encode($Data, JSON_PRETTY_PRINT) : $Data ; die(); @@ -116,7 +110,9 @@ // ---------------------------------------------------------------------- // MAIN // ---------------------------------------------------------------------- - + if (!$bDebug){ + header('Content-Type: application/json'); + } _wd('Start: '.date('Y-m-d H:i:s').'<style>body{background:#eee; color:#456;} .debug{background:#ddd; margin-bottom: 2px;} </style>'); @@ -148,15 +144,11 @@ if(!$sApiVersion){ - _quit('no paramm for api version was found.'); + _quit('ERROR: no param for api version was found.'); } if(!$sApiItem){ - _quit('ERROR: no paramm for item was found.'); + _quit('ERROR: no param for item was found.'); } - if(!in_array($sApiItem, $aApiItems)){ - _quit('ERROR: item ['.$sApiItem.'] is invalid.'); - } - switch ($sApiVersion){ @@ -245,7 +237,6 @@ break;; default: - // unreachable - see in_array before switch _quit('ERROR: item ['.$sApiItem.'] is invalid.'); } break;