Skip to content
Snippets Groups Projects
Commit 3ee24590 authored by hahn's avatar hahn
Browse files

task#3869 - initial stuff for API

small FIXES in server api: contenttype, JSON pretty print
parent 801a1686
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment