use of org.apache.bookkeeper.http.service.ErrorHttpService 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);
}
use of org.apache.bookkeeper.http.service.ErrorHttpService in project bookkeeper by apache.
the class VertxAbstractHandler method processRequest.
/**
* Process the request using the given httpEndpointService.
*/
void processRequest(HttpEndpointService httpEndpointService, RoutingContext context) {
HttpServerRequest httpRequest = context.request();
HttpServerResponse httpResponse = context.response();
HttpServiceRequest request = new HttpServiceRequest().setMethod(convertMethod(httpRequest)).setParams(convertParams(httpRequest)).setBody(context.getBodyAsString());
HttpServiceResponse response = null;
try {
response = httpEndpointService.handle(request);
} catch (Exception e) {
response = new ErrorHttpService().handle(request);
}
httpResponse.setStatusCode(response.getStatusCode());
httpResponse.end(response.getBody());
}
Aggregations