コード例 #1
0
ファイル: Endpoint.php プロジェクト: teqneers/ext-direct
 /**
  * @param Request $request
  * @return Response
  */
 public function handleRequest(Request $request)
 {
     $directRequest = $this->requestFactory->createRequest($request);
     $directResponse = $this->router->handle($directRequest, $request);
     if ($directRequest->isFormUpload()) {
         $response = new UploadResponse($directResponse->getFirst());
     } else {
         $response = JsonResponse::create($directResponse);
     }
     if ($this->debug) {
         $response->setEncodingOptions(JSON_PRETTY_PRINT);
     }
     return $response;
 }
コード例 #2
0
 public function testCreateRequestFailsWhenMethodIsDelete()
 {
     $factory = new RequestFactory();
     $httpRequest = new HttpRequest();
     $httpRequest->setMethod(HttpRequest::METHOD_DELETE);
     $this->setExpectedException('TQ\\ExtDirect\\Router\\Exception\\BadRequestException', 'Only POST requests are allowed');
     $factory->createRequest($httpRequest);
 }