Skip to content
Snippets Groups Projects
Commit ae481ba9 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch 'task3869-api' into 'master'

Task3869 api

See merge request !108
parents 60afd3f3 3ee24590
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* GET /api/v1/projects/ * GET /api/v1/projects/
* GET /api/v1/project/[ID]/build/[name-of-branch] * GET /api/v1/project/[ID]/build/[name-of-branch]
* POST /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> * 2020-06-16 v0.9 <axel.hahn@iml.unibe.ch>
...@@ -22,14 +22,8 @@ ...@@ -22,14 +22,8 @@
$sDirClasses=__DIR__.'/../deployment/classes/'; $sDirClasses=__DIR__.'/../deployment/classes/';
require_once($sDirClasses.'/project.class.php'); require_once($sDirClasses.'/project.class.php');
require_once($sDirClasses.'logger.class.php'); require_once($sDirClasses.'logger.class.php');
$aApiItems=array(
'project',
'projects',
'help',
);
$iMaxAge=60; $iMaxAge=60;
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
...@@ -70,7 +64,7 @@ ...@@ -70,7 +64,7 @@
*/ */
function _done($Data){ function _done($Data){
echo is_array($Data) echo is_array($Data)
? json_encode($Data, 1, JSON_PRETTY_PRINT) ? json_encode($Data, JSON_PRETTY_PRINT)
: $Data : $Data
; ;
die(); die();
...@@ -116,7 +110,9 @@ ...@@ -116,7 +110,9 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// MAIN // MAIN
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
if (!$bDebug){
header('Content-Type: application/json');
}
_wd('Start: '.date('Y-m-d H:i:s').'<style>body{background:#eee; color:#456;} _wd('Start: '.date('Y-m-d H:i:s').'<style>body{background:#eee; color:#456;}
.debug{background:#ddd; margin-bottom: 2px;} .debug{background:#ddd; margin-bottom: 2px;}
</style>'); </style>');
...@@ -148,15 +144,11 @@ ...@@ -148,15 +144,11 @@
if(!$sApiVersion){ if(!$sApiVersion){
_quit('no paramm for api version was found.'); _quit('ERROR: no param for api version was found.');
} }
if(!$sApiItem){ 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){ switch ($sApiVersion){
...@@ -245,7 +237,6 @@ ...@@ -245,7 +237,6 @@
break;; break;;
default: default:
// unreachable - see in_array before switch
_quit('ERROR: item ['.$sApiItem.'] is invalid.'); _quit('ERROR: item ['.$sApiItem.'] is invalid.');
} }
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment