mirror of
https://github.com/sctn4elk/CustomerRewardsRESTAPI.git
synced 2025-01-09 15:04:29 -06:00
58 lines
2.0 KiB
PHP
58 lines
2.0 KiB
PHP
<?php
|
|
header("Content-Type: application/json");header("Access-Control-Allow-Origin: *");
|
|
header("Content-Type: application/json; charset=UTF-8");
|
|
header("Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,DELETE");
|
|
header("Access-Control-Max-Age: 3600");
|
|
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
|
|
/*
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/EmptyPHP.php to edit this template
|
|
*/
|
|
/* USAGE
|
|
* https://localhost/index.php/{MODULE_NAME}/{METHOD_NAME}?limit={LIMIT_VALUE}
|
|
* http://localhost/index.php/customer/process/list?limit=20
|
|
*/
|
|
require __DIR__ . "/include/bootstrap.php";
|
|
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
|
$uri = explode( '/', $uri );
|
|
//Set uri module location position to 1 for production, 2 for testing
|
|
$uri_pos = 2;
|
|
|
|
/* When testing with UniServer the URI array placement position will be
|
|
* incremented by 1 due to the folder addition
|
|
* http://localhost/CustomerRewards/index.php/customer/process/select?limit=5
|
|
* uri[1] = folder
|
|
* uri[2] = index
|
|
* uri[3] = module
|
|
* uri[4] = action
|
|
* uri[5] = parmeters
|
|
*/
|
|
|
|
if (!isset($uri[$uri_pos]) || !isset($uri[$uri_pos+1]) || !isset($uri[$uri_pos+2])) {
|
|
header("HTTP/1.1 404 Not Found");
|
|
exit();
|
|
}
|
|
|
|
switch($uri[$uri_pos + 1]) {
|
|
case "purchase":
|
|
header("HTTP/1.1 404 Module Not Defined");
|
|
exit();
|
|
//require PROJECT_ROOT_PATH . "/Controller/Api/PurchaseController.php";
|
|
//$objFeedController = new PurchaseController();
|
|
break;
|
|
|
|
case "customer":
|
|
require PROJECT_ROOT_PATH . "/Controller/Api/CustomerController.php";
|
|
$objFeedController = new CustomerController();
|
|
break;
|
|
|
|
default:
|
|
header("HTTP/1.1 404 Module Not Found");
|
|
exit();
|
|
break;
|
|
}
|
|
|
|
$strMethodName = $uri[$uri_pos + 2] . 'Action';
|
|
$objFeedController->{$strMethodName}($uri[$uri_pos + 3]);
|
|
|