Sha256: 276bd4e97a1443b2b4cd67399268bfaa870c0d915745a6bf81c9c13b340dda38
Contents?: true
Size: 773 Bytes
Versions: 3
Compression:
Stored size: 773 Bytes
Contents
module Miso #Rack middleware that intercept request to the Rack application #rewrite the path so that is seems to target the base URL. class Rewrite #Request env variable to rewrite. @@REWRITE= ['REQUEST_PATH', 'PATH_INFO', 'REQUEST_URI'] #Receive the app and the option list (for now only the :app_path). def initialize (app, option) @app = app @path = option[:app_path] end #Execute request. def call(env) rewritePath(env) status, headers, response = @app.call(env) [status, headers, response] end private #Rewrite the path in the original request. def rewritePath(env) @@REWRITE.each do |key| env[key] = env[key].gsub(@path, '') end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
misosoup-0.1.2 | lib/miso/rewrite.rb |
misosoup-0.1.1 | lib/miso/rewrite.rb |
misosoup-0.1.0 | lib/miso/rewrite.rb |