CustomerRewardsRESTAPI/index.php

54 lines
1.7 KiB
PHP
Raw Normal View History

2024-04-15 11:38:59 -05:00
<?php
header("Content-Type: application/json");
/*
* 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;
2024-04-15 11:38:59 -05:00
/* 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])) {
2024-04-15 11:38:59 -05:00
header("HTTP/1.1 404 Not Found");
exit();
}
switch($uri[$uri_pos + 1]) {
2024-04-15 11:38:59 -05:00
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]);
2024-04-15 11:38:59 -05:00