add content-type for sentinel spring cloud gateway fallback

pull/658/head
fangjian0423 6 years ago
parent d59219fd33
commit f1a269d7fa

@ -17,6 +17,7 @@
package org.springframework.cloud.alibaba.sentinel.gateway;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
/**
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
@ -40,6 +41,10 @@ public class FallbackProperties {
* Response Status for `response` mode.
*/
private Integer responseStatus = HttpStatus.TOO_MANY_REQUESTS.value();
/**
* Content-Type for `response` mode.
*/
private String contentType = MediaType.APPLICATION_JSON_UTF8.toString();
public String getMode() {
return mode;
@ -77,4 +82,12 @@ public class FallbackProperties {
return this;
}
public String getContentType() {
return contentType;
}
public FallbackProperties setContentType(String contentType) {
this.contentType = contentType;
return this;
}
}

@ -111,7 +111,8 @@ public class SentinelSCGAutoConfiguration {
Throwable t) {
return ServerResponse
.status(fallbackProperties.getResponseStatus())
.contentType(MediaType.APPLICATION_JSON_UTF8)
.contentType(MediaType
.valueOf(fallbackProperties.getContentType()))
.body(fromObject(fallbackProperties.getResponseBody()));
}
});

Loading…
Cancel
Save