perpetuum mobile
15. 08. 2014. api * ruby

API - design, implementation, testing

Rails API versioning

It is a good idea to keep the API in its own namespace. If along with the API (json/xml) html will be served, the api endpoints could be in their own subdomain (api.site.com) or in the path (site.com/api). If only API will be served from the server, than it may be enough to just separate namespaces for each version. In this case, routes can look like this:

ApiConstraints check the correct version in the header:

And here’s the step for testing the version in the header with cucumber:

Resources


###Testing  the API

Resources

CSRF

skip_before_filter :verify_authenticity_token

Resources