Clean up Api call

This commit is contained in:
DESKTOP-GBA0BK8\Admin
2023-04-16 14:30:27 -04:00
parent 666c2da6c8
commit e74070ca1f
2 changed files with 31 additions and 26 deletions
+30 -25
View File
@@ -23,31 +23,7 @@ class WrenchApi extends BaseController
return view('welcome_message',$data); return view('welcome_message',$data);
} }
public function apigate(){ private function endPointList(){
/*
//$request = service('request');
header('Access-Control-Allow-Origin: *');
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
//header('Access-Control-Allow-Credentials: true ');
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
header('Content-type: application/json');
*/
// what is the endpoint
$uri = urldecode(current_url(true));
$findme = '?';
$pos = strpos($uri, $findme);
if ($pos > 5) {
$uri = substr($uri, 0, $pos);
}
log_message('critical', "API-GATE URI -> ".$uri );
$pieces = explode('/', $uri);
$psc = count($pieces);
$endpoint = $psc > 0 ? $pieces[$psc - 1] : '';
log_message('critical', "Enpoint-> ".$endpoint );
$endpoints = [ $endpoints = [
'apigate' => ['POST'], 'apigate' => ['POST'],
@@ -89,6 +65,35 @@ class WrenchApi extends BaseController
'disableaccount' => ['POST'], 'disableaccount' => ['POST'],
'myjobs' => ['POST'] 'myjobs' => ['POST']
]; ];
return $endpoints;
}
public function apigate(){
/*
//$request = service('request');
header('Access-Control-Allow-Origin: *');
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
//header('Access-Control-Allow-Credentials: true ');
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
header('Content-type: application/json');
*/
// what is the endpoint
$uri = urldecode(current_url(true));
$findme = '?';
$pos = strpos($uri, $findme);
if ($pos > 5) {
$uri = substr($uri, 0, $pos);
}
log_message('critical', "API-GATE URI -> ".$uri );
$pieces = explode('/', $uri);
$psc = count($pieces);
$endpoint = $psc > 0 ? $pieces[$psc - 1] : '';
log_message('critical', "Enpoint-> ".$endpoint );
$endpoints = $this->endPointList();
$res1 = []; $res1 = [];
if (array_key_exists($endpoint, $endpoints)) { if (array_key_exists($endpoint, $endpoints)) {
+1 -1
View File
@@ -11,7 +11,7 @@
"source": "https://github.com/bcit-ci/CodeIgniter" "source": "https://github.com/bcit-ci/CodeIgniter"
}, },
"require": { "require": {
"php": ">=5.3.7", "php": "^7.3 || ^8.0",
"facebook/graph-sdk" : "^5.7", "facebook/graph-sdk" : "^5.7",
"firebase/php-jwt": "^6.2", "firebase/php-jwt": "^6.2",
"phpseclib/phpseclib": "^3.0", "phpseclib/phpseclib": "^3.0",