org.springframework.web.reactive.function.server.ServerResponse设置响应头

  • 记录一下
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));

函数式路由匹配,进行响应头的设置。

相关推荐
阿维的博客日记10 小时前
MultipartFile 是不是表示仅仅是一个分片?
java·后端·spring·multipartfile
程序员无隅10 小时前
Coding Agent 为什么压缩上下文后还能继续工作?上下文模块设计拆解
java·开发语言·数据库
Python+9910 小时前
Java 枚举类(Enum)详解:从基础到高级应用
java·开发语言·python
二炮手亮子11 小时前
浅记java线程池
java·开发语言
一路向北North11 小时前
Spring Security OAuth2.0(23):分布式系统授权-转发明文给微服务
java·spring·微服务
爱吃牛肉的大老虎13 小时前
rust基础之环境搭建
java·开发语言·rust
tellmewhoisi14 小时前
多版本共用redis的token有效期校验(过期重新登录)
java·redis·缓存
疯狂打码的少年14 小时前
【软件工程】结构化设计:模块独立性与耦合内聚
java·开发语言·笔记·软件工程
乐观的Terry14 小时前
3、数据库设计与领域实体
java·数据库·spring boot·spring cloud·ai编程
C++、Java和Python的菜鸟14 小时前
第4章 后端Web基础(基础知识)
java·开发语言