Esempio n. 1
0
 /**
  * Perform request
  *
  * @param string $method
  * @param string $uri
  * @param array $params
  * @param array $server
  *
  * @throws \Slim\Exception\MethodNotAllowedException
  * @throws \Slim\Exception\NotFoundException
  */
 public function request($method, $uri, array $params = [], array $server = [])
 {
     $method = strtoupper($method);
     switch ($method) {
         case 'POST':
         case 'PUT':
         case 'PATCH':
         case 'DELETE':
             $this->server['slim.input'] = http_build_query($params);
             $query = '';
             break;
         case 'GET':
         default:
             $query = http_build_query($params);
             break;
     }
     $server = array_merge($this->server, $server, ['REQUEST_URI' => $uri, 'REQUEST_METHOD' => $method, 'QUERY_STRING' => $query]);
     $env = Http\Environment::mock($server);
     $request = Http\Request::createFromEnvironment($env);
     $response = new Http\Response();
     $response = $this->app->__invoke($request, $response);
     $this->request = $request;
     $this->response = $response;
 }