We are considering using a header field to specify the REST API version in our spring boot application.
How can we tell spring boot to redirect calls depending on a header value?
I am dreaming about something like this:
@Path("/my/rest/path")
@HeaderMapping(headerName="ApiVersion", headerValue="V1")
public class V1Controller {
@GetMapping
public String myMethod() {
}
}
== and ==
@Path("/my/rest/path")
@HeaderMapping(headerName="ApiVersion", headerValue="V2")
public class V2Controller {
@GetMapping
public String myMethod() {
}
}
for HTTP requests like these:
GET /my/rest/path HTTP/1.1
Accept: application/json
ApiVersion: V1
== or ==
GET /my/rest/path HTTP/1.1
Accept: application/json
ApiVersion: V2