Skip to content
Marlon Carvalho edited this page Jul 17, 2015 · 2 revisions

Darter allows you to choose two versioning strategies: Path or Header. In the Path strategy, the version is provided in the URI, like in http://domain/<version>/beers. To use this strategy, use the @Version annotation and set the using attribute to Using.HEADER.

@API(path: 'beers')
@Version(version: 'v1', using: Using.PATH)
class BeerAPI {
}

In the other hand, the header strategy searches the Accept header for the version. Notice that you must follow a convention to create this header. It must be something like application/vnd.<vendor>.<version>+<format>. We didn't invent it, it's in the RFC! Hence, when you choose the Header strategy, you are forced to declare two more parameters to the @Version annotation: vendor and format.

@API(path: 'categories')
@Version(version: 'v1', vendor: 'company', format: Format.JSON, using: Using.HEADER)
class BeerAPI {
}
Clone this wiki locally