Skip to content

kstewart/sixflags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SixFlags - Rack Middleware for RESTful API Feature Flags

Because deploying features straight to production is a Great Adventure®!

SixFlags is a Rack middleware that implements the concept of feature flags, but for RESTful APIs. If you are implementing a standalone API (or your webapp is a client of your API), SixFlags allows you to cleanly enable/disable functionality without injecting a ton of conditionals in your code.

Usage

To configure the SixFlags middleware, specify a prefix for the Redis keys and, optionally, the host and port on which your Redis instance is running:

require 'sixflags'
use SixFlags, { 
	:host => "127.0.0.1", 
	:port => 6379, 
	:prefix => "myapp:prefix"
}

In Redis, use the hash commands to specify which URI/method combinations are enabled. You can use a wildcard to enable all HTTP methods:

HSET "#{:prefix}:#{RACK_ENV}" "#{URI}" ['*']

Or, explicitly list which methods to enable:

HSET "#{:prefix}:#{RACK_ENV}" "#{URI}" ['GET', 'POST', 'HEAD']

Note: The absence of a URI or URI/method combination is implicitly interpreted as that "feature" being disabled.

SixFlags will parse the incoming request and perform a lookup against the database. There are 3 possible responses:

  • 200: URI matched and method enabled. Pass through to the next Rack middleware in the stack.
  • 403: URI matched and method disabled. Feature not available for this request.
  • 404: URI did not match any entries in the configuration database.

TODO

  • Package as a gem
  • Write a small Sinatra application to administer the configuration database
  • Add more tests

Resources

Author

License

See LICENSE.

About

Rack Middleware for RESTful API Feature Flags

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages