Client version headers are used to support backwards compatibility for breaking REST interface changes.
Using them, you're able to return different responses based on which client is making a request.
The APIs involved with defining client version headers are:
- {@link oajr.annotation.Rest}
- {@link oajr.annotation.Rest#clientVersionHeader() clientVersionHeader}
- {@link oajr.annotation.RestOp}
- {@link oajr.annotation.RestOp#clientVersion() clientVersion}
- {@link oajr.RestContext.Builder}
- {@link oajr.RestContext.Builder#clientVersionHeader(String) clientVersionHeader(String)}
| // Option #1 - Defined via annotation resolving to a config file setting with default value.
| @Rest(clientVersionHeader="Client-Version")
| public class MyResource {
|
| // Call this method if Client-Version is at least 2.0.
| // Note that this also matches 2.0.1.
| @RestGet(path="/foobar", clientVersion="2.0")
| public Object method1() {
| ...
| }
|
| // Call this method if Client-Version is at least 1.1 but less than 2.0.
| @RestGet(path="/foobar", clientVersion="[1.1,2.0)")
| public Object method2() {
| ...
| }
|
| // Call this method if Client-Version is less than 1.1.
| @RestGet(path="/foobar", clientVersion="[0,1.1)")
| public Object method3() {
| ...
| }