No commit activity in last 3 years
No release in over 3 years
Version your Rack based API's using headers either through middleware or routing constraints
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.6.2
= 0.9.2.2
~> 2.12.0

Runtime

>= 1.0
 Project Readme

RackApiVersioning

Build Status

Version your Rack based API's using headers either through middleware or routing constraints.

Installation

Add this line to your application's Gemfile:

gem 'rack-api-versioning'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rack-api-versioning

Usage in Rails

    Your::Application.routes.draw do
      constraints RackApiVersioning::Constraint.new( :target_version => 3,
                                                     :default_version => 2,
                                                     :app_name => "awesome-app",
                                                     :media_type => "json" ) do
    		scope :module => :v3 do
      		resources :orders, :only => [:create, :show] do

      	end
     	end
    end

Usage in any Rack app

    Rack::Builder.new do
      
      map '/' do        
        use RackApiVersioning::Middleware, 
          :app_name => "awesome-app",
          :default_version => 1,
          :target_version => 2

        run lambda { |env| 
          [200, {"Content-Type" => "text/html"}, "Testing RackApiVersioning"] 
        }
      end

      map "/new-improved-api" do
        use RackApiVersioning::Middleware, 
          :app_name => "awesome-app",
          :default_version => 2,
          :target_version => 3

        run lambda { |env| 
          [200, {"Content-Type" => "text/html"}, "Testing RackApiVersioning"] 
        } 
      end
      
    end