Client Versioning
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#clientVersionHeader() Rest(clientVersionHeader)}
- {@link oajr.RestContextBuilder#clientVersionHeader(String)}
- {@link oajr.annotation.RestMethod#clientVersion() RestMethod(clientVersion)}
// 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.
@RestMethod(name=GET, path="/foobar", clientVersion="2.0")
public Object method1() {
...
}
// Call this method if Client-Version is at least 1.1, but less than 2.0.
@RestMethod(name=GET, path="/foobar", clientVersion="[1.1,2.0)")
public Object method2() {
...
}
// Call this method if Client-Version is less than 1.1.
@RestMethod(name=GET, path="/foobar", clientVersion="[0,1.1)")
public Object method3() {
...
}
- {@link oajr.RestContext#REST_clientVersionHeader}