No commit activity in last 3 years
No release in over 3 years
This simple middleware sets anything in the X-#{prefix}-Cookie header to Cookie, and in the response will copy anything in Set-Cookie to X-#{prefix}-Set-Cookie. This can be useful to enable session management where an HTML client is accessing your API, which doesn't fully support cookies. We have found this to be the case in some Smart TV web applications, and in mobile apps written using frameworks such as Cordova
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 1.6
>= 0
 Project Readme

Rack::CookieRewrite

This is a Rack middleware to add extra headers which behave like the Cookie and Set-Cookie headers.

This simple middleware sets anything in the X-#{prefix}-Cookie header to Cookie, and in the response will copy anything in Set-Cookie to X-#{prefix}-Set-Cookie. This can be useful to enable session management where an HTML client is accessing your API, which doesn't fully support cookies. We have found this to be the case in some Smart TV web applications, and in mobile apps written using frameworks such as Cordova

Installation

Add this line to your application's Gemfile:

gem 'rack-cookie_rewrite'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rack-cookie_rewrite

Usage

In your config.ru, or where ever else you set up your Rack environment, add the following lines:

require 'rack/cookie_rewrite'
use Rack::CookieRewrite, 'MSP'

Then use cookies in your Rack application as normal.

In your client application, you can then use X-MSP-Cookie and X-MSP-Set-Cookie in lieu of normal Cookie commands. This means you will have to manually read and set these headers if you are sending requests that expect and set cookies.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/rack-cookie_rewrite/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request