Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove redirect. replaced by dynamic-reverse-proxy

  • Loading branch information...
commit 1e1045c81f730a0fe068f62c79e8eafb7236cd13 1 parent 24e31b5
Tobias Bielohlawek authored
Showing with 0 additions and 39 deletions.
  1. +0 −2  examples/basic/config.ru
  2. +0 −37 lib/nabaztag_hack_kit/redirect.rb
View
2  examples/basic/config.ru
@@ -2,11 +2,9 @@
$LOAD_PATH.unshift ::File.expand_path(::File.dirname(__FILE__) + '/lib')
require './server'
-require 'nabaztag_hack_kit/redirect'
$stdout.sync = true
use Rack::Reloader, 0
-use NabaztagHackKit::Redirect
run Basic::Server.new
View
37 lib/nabaztag_hack_kit/redirect.rb
@@ -1,37 +0,0 @@
-require 'open-uri'
-
-# a rack middleware to redirect(Proxy through) certain request to another service
-#
-# it's the prefered solution for developing, so your bunny still points to live server but any request
-# get forwarded to dev machine
-module NabaztagHackKit
- class Redirect
- def initialize(app)
- @app = app
- end
-
- def call(env)
- path = env['PATH_INFO']
- query = env['QUERY_STRING']
- if path =~ /\/redirect/
- req = Rack::Request.new(env)
- if (to = req.params["to"]) && !to.empty?
- @redirect = to
- render "Redirect turned on to #{@redirect}"
- else
- @redirect = nil
- render "Redirect turned off"
- end
- elsif @redirect
- render open("#{@redirect}#{path}?#{query}")
- else
- @app.call(env)
- end
- end
-
- private
- def render(response)
- [response.status.first.to_i, {"Content-Type" => response.content_type}, Array(response)]
- end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.