|
@@ -0,0 +1,52 @@
|
|
|
+package com.idatabank.zuulgatewayapp.zuulgatewayapp;
|
|
|
+
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.client.ClientHttpResponse;
|
|
|
+
|
|
|
+public class GatewayClientResponse implements ClientHttpResponse {
|
|
|
+ private HttpStatus httpStatus;
|
|
|
+ private String message;
|
|
|
+
|
|
|
+ public GatewayClientResponse(HttpStatus httpStatus, String message) {
|
|
|
+ this.httpStatus = httpStatus;
|
|
|
+ this.message = message;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpStatus getStatusCode() throws IOException {
|
|
|
+ return httpStatus;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getRawStatusCode() throws IOException {
|
|
|
+ return httpStatus.value();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getStatusText() throws IOException {
|
|
|
+ return httpStatus.getReasonPhrase();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void close() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public InputStream getBody() throws IOException {
|
|
|
+ return new ByteArrayInputStream(message.getBytes());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpHeaders getHeaders() {
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ return headers;
|
|
|
+ }
|
|
|
+}
|