From 9b6956b8df6ec77b7d7ad964e3e346b95c0d549a Mon Sep 17 00:00:00 2001 From: dartpopikyardo Date: Mon, 5 Sep 2016 14:46:48 +0300 Subject: [PATCH] wip issue #8 --- .../apigateway/controller/GatewayController.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/java-spring/api-gateway-service/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/apigateway/controller/GatewayController.java b/java-spring/api-gateway-service/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/apigateway/controller/GatewayController.java index fe1db77..f5338c1 100755 --- a/java-spring/api-gateway-service/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/apigateway/controller/GatewayController.java +++ b/java-spring/api-gateway-service/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/apigateway/controller/GatewayController.java @@ -59,18 +59,12 @@ public class GatewayController { @RequestMapping(value = "/api/**", method = {GET, POST}) @ResponseBody - public String proxyRequest(HttpServletRequest request) throws NoSuchRequestHandlingMethodException, IOException, URISyntaxException { + public ResponseEntity proxyRequest(HttpServletRequest request) throws NoSuchRequestHandlingMethodException, IOException, URISyntaxException { HttpUriRequest proxiedRequest = createHttpUriRequest(request); logger.info("request: {}", proxiedRequest); HttpResponse proxiedResponse = httpClient.execute(proxiedRequest); logger.info("Response {}", proxiedResponse.getStatusLine().getStatusCode()); - return read(proxiedResponse.getEntity().getContent()); - } - - private HttpHeaders processHeaders(Header[] headers) { - HttpHeaders result = new HttpHeaders(); - Stream.of(headers).forEach( h -> result.set(h.getName(), h.getValue())); - return result; + return new ResponseEntity<>(read(proxiedResponse.getEntity().getContent()), HttpStatus.valueOf(proxiedResponse.getStatusLine().getStatusCode())); } private HttpUriRequest createHttpUriRequest(HttpServletRequest request) throws URISyntaxException, NoSuchRequestHandlingMethodException, IOException {