Skip to content

Commit

Permalink
Merge pull request #18 from gfbio/13-feature-handling-of-unknown-serv…
Browse files Browse the repository at this point in the history
…ice-requests

[#13] Config w/ implemented services for index.php
  • Loading branch information
airnst authored Oct 29, 2024
2 parents 86bd855 + d191fa1 commit 0df2662
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 11 additions & 5 deletions api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@

include("utils.php");
include("pdi.php");
include("../config.php");

$padding_width = 4;
$service = get_url_parameter('service');

//TODO check if exists
//echo "service: '".$service."'";
if(!in_array($service, $services)){
header('Content-Type: application/json; charset=utf-8');
http_response_code (404);
$output = array();
$output["error_code"] = 404;
$output["error_message"] = "Service not found";
$output["available_services"] = $services;
echo json_encode($output);
return;
}

if($service == "transformations"){
$transformation = get_url_parameter('transformation');
Expand Down Expand Up @@ -321,9 +330,6 @@
http_response_code (404);
echo "unknonwn job";
}
}else{
http_response_code (404);
echo "unknonwn service";
}

function python_transformation($job_json,$transformation_json){
Expand Down
6 changes: 6 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

# Available services
$services = array('transformations', 'transform');

?>

0 comments on commit 0df2662

Please sign in to comment.