README.md in versioncake-0.3.2 vs README.md in versioncake-0.4.0

- old
+ new

@@ -17,10 +17,12 @@ ``` - Gracefully degrade requests to the latest supported version - Clients can request API versions through different strategies - Dry your controller logic with exposed helpers +Check out https://github.com/bwillis/350-rest-api-versioning for a comparison of traditional versioning approaches and a versioncake implementation. + ## Install ``` gem install versioncake ``` @@ -166,12 +168,17 @@ ```ruby config.view_version_extraction_strategy = :query_parameter # [:http_header, :http_accept_parameter] ``` These are the available strategies: - **query_parameter**: version in the url query parameter, for testing or to override for special case i.e. ```http://localhost:3000/posts.json?api_version=1``` (This is the default.) - - **http_header**: Api version HTTP header ie. ```API-Version: 1``` + - **http_header**: Api version HTTP header ie. ```X-API-Version: 1``` - **http_accept_parameter**: HTTP Accept header ie. ```Accept: application/xml; version=1``` [why do this?](http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-rest-or-http#i_want_my_api_to_be_versioned) - - **custom**: `lambda {|request| request.headers["HTTP_X_API_VERSION"].to_i }` takes the request object and must return an integer + - **custom**: `lambda {|request| request.headers["HTTP_X_MY_VERSION"].to_i }` takes the request object and must return an integer + +The strategies use a default string of `api_version`, but that can be changed: +```ruby +config.view_version_string = "special_version_parameter_name" +``` ### Version your views When a client makes a request to your controller the latest version of the view will be rendered. The latest version is determined by naming the template or partial with a version number that you configured to support.