Skip to content

Commit

Permalink
changed default behavior to echo responses
Browse files Browse the repository at this point in the history
  • Loading branch information
nikirago committed Apr 5, 2021
1 parent 0cf15af commit 16809af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions config/fsl_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function configure()
option('base_uri', "/"); //set if app is not in web root directory but in a subdirectory...
option('session', 'fsl'); // enable with a specific session name
option('behind_proxy', FALSE); //enabled if behind gateway or balancer like Kong
option('release', '20210405'); //enabled if behind gateway or balancer like Kong

//##############################################
//encryption configuration
Expand Down
8 changes: 4 additions & 4 deletions controllers/fsl_controllers.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ function api()
//explode line into array
$line = explode("<>", $line);
$arr = array('Joke' => array('Opener' => $line[0], 'Punchline' => trim($line[1]), 'Processing Time' => process_time()));
$credits = array('SourceCode' => 'https://github.com/yesinteractive/dadjokes');
$credits = array('DadJokesInfo' => array('SourceCode' => 'https://github.com/yesinteractive/dadjokes','Version' => option('release')));

$headers = getallheaders();

if((empty(params('uri_param'))) || (params('uri_param')!="noecho")){
$request = ["Request"=>["Headers"=>$headers,
$request = ["RequestEcho"=>["Headers"=>$headers,
"Method"=>$_SERVER['REQUEST_METHOD'],
"Origin"=>$_SERVER['REMOTE_ADDR'],
"URI"=>(option('behind_proxy') == TRUE || getenv("DADJOKES_BEHIND_PROXY") == "TRUE" ? $_REQUEST['uri'] : preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI'])),
Expand All @@ -42,10 +42,10 @@ function api()
. (option('behind_proxy') == TRUE || getenv("DADJOKES_BEHIND_PROXY") == "TRUE" ? $headers['X-Forwarded-Host'].$_REQUEST['uri']: "$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),

]];
status(202); //returns HTTP status code of 202
status(200); //returns HTTP status code of 202
return json(array_merge($arr,$request,$credits),JSON_UNESCAPED_SLASHES);
} else{
status(202); //returns HTTP status code of 202
status(200); //returns HTTP status code of 202
return json(array_merge($arr,$credits),JSON_UNESCAPED_SLASHES);
}

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Access [http://dadjokes.online](http://dadjokes.online) to see the service in ac
"Punchline": "I left my food in the oven for too long.",
"Processing Time": "0.001223"
},
"Request": {
"RequestEcho": {
"Headers": {
"Host": "dadjokes.online",
"Connection": "keep-alive",
Expand Down

0 comments on commit 16809af

Please sign in to comment.