Search in sources :

Example 1 with Response

use of com.twitter.finagle.http.Response in project bookkeeper by apache.

the class TwitterAbstractHandler method processRequest.

/**
 * Process the request using the given httpEndpointService.
 */
Future<Response> processRequest(HttpEndpointService httpEndpointService, Request request) {
    HttpServiceRequest httpServiceRequest = new HttpServiceRequest().setMethod(convertMethod(request)).setParams(convertParams(request)).setBody(request.contentString());
    HttpServiceResponse httpServiceResponse = null;
    try {
        httpServiceResponse = httpEndpointService.handle(httpServiceRequest);
    } catch (Exception e) {
        httpServiceResponse = new ErrorHttpService().handle(httpServiceRequest);
    }
    Response response = Response.apply();
    response.setContentString(httpServiceResponse.getBody());
    response.statusCode(httpServiceResponse.getStatusCode());
    return Future.value(response);
}
Also used : Response(com.twitter.finagle.http.Response) HttpServiceResponse(org.apache.bookkeeper.http.service.HttpServiceResponse) ErrorHttpService(org.apache.bookkeeper.http.service.ErrorHttpService) HttpServiceRequest(org.apache.bookkeeper.http.service.HttpServiceRequest) HttpServiceResponse(org.apache.bookkeeper.http.service.HttpServiceResponse)

Aggregations

Response (com.twitter.finagle.http.Response)1 ErrorHttpService (org.apache.bookkeeper.http.service.ErrorHttpService)1 HttpServiceRequest (org.apache.bookkeeper.http.service.HttpServiceRequest)1 HttpServiceResponse (org.apache.bookkeeper.http.service.HttpServiceResponse)1