Exemplo n.º 1
0
/**
 * Processes the request to build a response.
 *
 * @param $routes  array
 * @param $options array
 * @return string
 */
function run(array $routes, array $options = [])
{
    $paramSet = isset($options['param_set']) ? $options['param_set'] : [];
    $params = Request\prepareParams($paramSet);
    $request = Request\parse($params);
    $response = Response\create();
    $pipeline = wrapPipeline($request, $routes, $options);
    return Util\pipe($pipeline, ['request' => $request, 'response' => $response]);
}
Exemplo n.º 2
0
 public function testParseQueryString()
 {
     // REQUEST_URI isn't provided by php-cli :(
     $_SERVER['REQUEST_URI'] = '/?test=true&';
     $_SERVER['QUERY_STRING'] = 'test=true&';
     $request = Request\parse();
     $this->assertNotNull($request);
     $this->assertEquals($request['uri'], '');
     $this->assertEquals($request['server'], $_SERVER);
     $this->assertEquals($request['params'], []);
 }