【发布时间】:2021-10-31 09:00:40
【问题描述】:
我设置了一个 Spring Boot 服务器,它可以成功接收请求。它已使用OpenAPI 进行设置,以生成处理参数转换的端点定义。
现在,我的问题是我现在想检查不属于请求参数的标头,而只是将标头作为请求的一部分。
在我设置的另一个 Spring Boot 应用程序中,我通过添加到控制器来实现这一点
@Autowired
NativeWebRequest request;
允许访问传入请求。
但是,在我当前的应用程序中,这始终是 null - 我无法获得任何标题数据。我怀疑我在 SpringBoot 应用程序设置中做错了什么。
// Athena pulled in KeycloakAutoConfiguration when KeycloakAuthorization was added. However, the class
// is not part of the Athena application - so exclude by name since we cannot reference the class here.
@EnableAutoConfiguration(
excludeName = { "org.keycloak.adapters.springboot.KeycloakAutoConfiguration"},
exclude = {
DataSourceAutoConfiguration.class,
ErrorMvcAutoConfiguration.class,
HttpEncodingAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
ThymeleafAutoConfiguration.class,
WebSocketMessagingAutoConfiguration.class,
OAuth2ClientAutoConfiguration.class,
})
@SpringBootConfiguration
public class AthenaApplication extends SpringBootServletInitializer
【问题讨论】:
-
您是否尝试过将
@RequestHeader Map<String, String> headers作为参数传递给您的控制器方法?
标签: java spring-boot openapi