fixed GatewayController

This commit is contained in:
dartpopikyardo
2016-09-16 20:51:16 +03:00
parent 459e2915a3
commit 93fc13e7a8

View File

@@ -16,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -32,8 +31,7 @@ import java.net.URISyntaxException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static org.springframework.web.bind.annotation.RequestMethod.GET; import static org.springframework.web.bind.annotation.RequestMethod.*;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
/** /**
* Created by popikyardo on 15.01.16. * Created by popikyardo on 15.01.16.
@@ -57,7 +55,7 @@ public class GatewayController {
.build(); .build();
} }
@RequestMapping(value = "/api/**", method = {GET, POST}) @RequestMapping(value = "/api/**", method = {GET, POST, DELETE})
@ResponseBody @ResponseBody
public ResponseEntity<String> proxyRequest(HttpServletRequest request) throws NoSuchRequestHandlingMethodException, IOException, URISyntaxException { public ResponseEntity<String> proxyRequest(HttpServletRequest request) throws NoSuchRequestHandlingMethodException, IOException, URISyntaxException {
HttpUriRequest proxiedRequest = createHttpUriRequest(request); HttpUriRequest proxiedRequest = createHttpUriRequest(request);
@@ -69,7 +67,7 @@ public class GatewayController {
private HttpHeaders processHeaders(Header[] headers) { private HttpHeaders processHeaders(Header[] headers) {
HttpHeaders result = new HttpHeaders(); HttpHeaders result = new HttpHeaders();
Stream.of(headers).filter(h -> h.getName().equalsIgnoreCase("Content-Type")).forEach( h -> result.set(h.getName(), h.getValue())); Stream.of(headers).filter(h -> h.getName().equalsIgnoreCase("Content-Type")).forEach(h -> result.set(h.getName(), h.getValue()));
return result; return result;
} }