Socket
Book a DemoInstallSign in
Socket

rack-rest_api_versioning

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rack-rest_api_versioning

0.0.2
bundlerRubygems
Version published
Maintainers
1
Created
Source

= Rack REST API Versioning

This Rack middleware adds support for RESTful API versioning. According to RESTful best practices, the API version should be specified using content negotiation and custom vendor MIME types. For example, if your application's API supports multiple versions, a client can ask for a specific version like this:

GET /foo HTTP/1.1 Accept: application/vnd.foo.bar-v2+xml

Where "application/vnd.foo.bar-v2+xml" is vendor MIME type your application defines.

See this article: http://barelyenough.org/blog/2008/05/versioning-rest-web-services/ for more information about this practice.

This middleware is used like any other rack middleware:

use Rack::RestApiVersioning

When used, it extracts the version from the Accept header, and makes it available in the Rack environment hash as "api_version":

app = lambda { |env puts env['api_version'] [200, {}, []] }

To simplify testing and debugging, this middleware also allows the version to be overriden using simple query string parameter:

GET /foo?version=2 HTTP/1.1

This will ask for version 2, no matter what the Accept header is set to.

Finally, a default version can be specified. This will be used if no version can be extracted:

use Rack::RestApiVersioning, :default_version => '2.0'

== Legal

Copyright (c) 2010 Adam Cigánek adam.ciganek@gmail.com. Released under the terms of MIT License: www.opensource.org/licenses/mit-license.php

FAQs

Package last updated on 09 Jun 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.