【发布时间】:2020-01-13 09:23:25
【问题描述】:
我正在使用 Spring Boot V2.2.2.RELEASE 并使用自定义标头进行 API 版本控制。我开发了这样的小端点:
@GetMapping(value = "/student/header", headers = {"X-API-VERSION=2", "X-API-VERSION=1"})
public StudentV1 headerV2() {
return new StudentV1("Bob Charlie");
}
当我点击curl -X GET http://localhost:8080/student/header -H 'x-api-version: 1' 时,我得到了错误。
{
"timestamp": "2020-01-13T09:20:20.087+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/student/header"
}
如果我使用headers = {"X-API-VERSION=2"},那么它可以工作,但如果我使用headers = {"X-API-VERSION=2", "X-API-VERSION=1"},那么事情就停止了。
@GetMapping(value = "/student/header", headers = {"X-API-VERSION=2"})
public StudentV1 headerV2() {
return new StudentV1("Bob Charlie");
}
【问题讨论】:
标签: spring swagger spring-rest