- 记录一下
java
String host = serverRequest.uri().getHost();
Consumer<HttpHeaders> headersConsumer = consumer -> {
consumer.setAccessControlAllowOrigin(host);
consumer.setAccessControlAllowCredentials(true);
consumer.set("Access-Control-Allow-Headers","*");
consumer.set("Access-Control-Allow-Methods", "*");
consumer.setAccessControlMaxAge(3600);
};
ServerResponse.status(HttpStatus.OK).headers(headersConsumer).body(BodyInserters.fromValue(result));
函数式路由匹配,进行响应头的设置。