Skip to content

Commit 2f6b5c7

Browse files
committed
Refactor fillCorsHeader to be non-static for proper dependency injection
1 parent 8d66ec0 commit 2f6b5c7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/src/main/java/io/kafbat/ui/exception/GlobalErrorWebExceptionHandler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.function.Consumer;
1313
import java.util.stream.Collectors;
1414
import java.util.stream.Stream;
15+
import org.springframework.beans.factory.annotation.Autowired;
1516
import org.springframework.boot.autoconfigure.web.WebProperties;
1617
import org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler;
1718
import org.springframework.boot.web.reactive.error.ErrorAttributes;
@@ -38,6 +39,9 @@
3839
@Order(Ordered.HIGHEST_PRECEDENCE)
3940
public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler {
4041

42+
@Autowired
43+
private CorsGlobalConfiguration corsGlobalConfiguration;
44+
4145
public GlobalErrorWebExceptionHandler(ErrorAttributes errorAttributes,
4246
ApplicationContext applicationContext,
4347
ServerCodecConfigurer codecConfigurer) {
@@ -151,7 +155,7 @@ private String requestId(ServerRequest request) {
151155
}
152156

153157
private Consumer<HttpHeaders> headers(ServerRequest request) {
154-
return CorsGlobalConfiguration::fillCorsHeader;
158+
return corsGlobalConfiguration::fillCorsHeader;
155159
}
156160

157161
private BigDecimal currentTimestamp() {

0 commit comments

Comments
 (0)