'0', 'GET' => '1', 'PUT' => '2', 'DELETE' => '3', 'HEAD' => '4', 'OPTIONS' => '5', 'PATCH' => '6' ); $request_type = $type[$_SERVER['REQUEST_METHOD']]; $api_uri = $_GET['uri']; $service = new MockModule(); switch ($result_type) { case 'success': { $result = $service->success($project_id, $api_uri, $request_type); break; } case 'failure': { $result = $service->failure($project_id, $api_uri, $request_type); break; } default: { exit('error result type.'); } } if ($result) { exit($result); } else { exit('sorry,this api without the mock data.'); } } /** * 获取高级mock结果 */ public function mock() { header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Methods:POST,GET,PUT,DELETE,PATCH,OPTIONS'); header('Access-Control-Allow-Headers:x-requested-with,content-type,x-custom-header,Accept,Authorization,other_header,x-csrf-token'); header("Content-type: application/json; charset=UTF-8"); $project_id = $_GET['projectID']; $type = array( 'POST' => '0', 'GET' => '1', 'PUT' => '2', 'DELETE' => '3', 'HEAD' => '4', 'OPTIONS' => '5', 'PATCH' => '6' ); $request_type = $type[$_SERVER['REQUEST_METHOD']]; $api_uri = $_GET['uri']; $module = new MockModule(); $result = $module->getMockResult($project_id, $api_uri, $request_type); if ($result) { $decoded_result = htmlspecialchars_decode($result); if ($decoded_result) { exit($decoded_result); } exit($result); } else { exit('sorry,this api without the mock data.'); } } }