From 16809af2f0921fb9ede51a477630e65e0c35bd8c Mon Sep 17 00:00:00 2001 From: "nick@yes-interactive.com" Date: Mon, 5 Apr 2021 20:02:08 +0000 Subject: [PATCH] changed default behavior to echo responses --- config/fsl_config.php | 1 + controllers/fsl_controllers.php | 8 ++++---- readme.md | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config/fsl_config.php b/config/fsl_config.php index 105c66c..676f797 100644 --- a/config/fsl_config.php +++ b/config/fsl_config.php @@ -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 diff --git a/controllers/fsl_controllers.php b/controllers/fsl_controllers.php index c8555e6..d0b8a28 100644 --- a/controllers/fsl_controllers.php +++ b/controllers/fsl_controllers.php @@ -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'])), @@ -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); } diff --git a/readme.md b/readme.md index a41597e..90e2c65 100644 --- a/readme.md +++ b/readme.md @@ -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",