Sha256: 5c04b9f42d3a7b4dfb32191deef60cc61c41c32f608eb71a8a4dc2e61046d01b
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
= rack-rewrite Rack middleware for request rewriting. == Example use Rack::Rewrite do on :method => 'get' do # When it sees /api or /test, it calls whatever is in the act block # on :path_info => %r{/(api|test)} do act { puts "hey way to go!" } pass end # When it sees /google, it makes a redirect to google with the value of the query string as the search # on :path_info => %r{/google.*} do redirect { "http://google.com/search?q=#{CGI.escape(query_string)}" } end # If a PATH_INFO starts with /valid_place, it strips it off and keeps on truckin' # on :path_info => %r{/valid_place/.*} do set(:path_info) { path_info[%r{/valid_place(/.*)}, 1] } pass end # If a PATH_INFO starts with /hello_kitty, add a kitty header equal to your query string # on :path_info => %r{/hello_kitty/.*} do act { header['kitty'] = query_string } pass end # If the request has a has a param of kitten=cute or kitten=happy, lets log it and pass it on! # on :params => {:kitten => /cute|happy/} do act { log('what a nice cat') } pass end fail end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
joshbuddy-rack-rewrite-0.0.3 | README.rdoc |
joshbuddy-rack-rewrite-0.0.4 | README.rdoc |