Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (23 sloc) 0.786 kb
<?php
namespace PHPMachine;
require dirname(__FILE__).'/src/Loader.php';
\PHPMachine\Loader::autoload();
function http_request($dispatchPath) {
$request = new \PHPMachine\Request();
$response = new \PHPMachine\Response();
$response = execute_request($request, $response, $dispatchPath);
$response->serve();
}
function execute_request(Request $request, Response $response, $dispatchPath) {
$dispatchList = require $dispatchPath;
$result = Dispatcher::dispatch($dispatchList, $request);
if ($result[0]===false) {
$response->set_status_code(404);
$body = ErrorHandler::handleError(404, $request, 'Resource was not found');
$response->write($body);
return $response;
}
else {
return \PHPMachine\DecisionCore::handleRequest($result[0], $request, $response);
}
}
Jump to Line
Something went wrong with that request. Please try again.