class Rack::OAuth2::Server::Admin::Mount
Rack
module that mounts the specified class on the specified path, and passes all other request to the application.
Attributes
klass[R]
match[R]
path[R]
Public Class Methods
mount(klass, path)
click to toggle source
# File lib/rack/oauth2/server/admin.rb, line 17 def mount(klass, path) @klass = klass @path = path @match = /^#{Regexp.escape(path)}(\/.*|$)?/ end
new(app)
click to toggle source
# File lib/rack/oauth2/server/admin.rb, line 26 def initialize(app) @pass = app @admin = self.class.klass.new end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/oauth2/server/admin.rb, line 31 def call(env) path = env["PATH_INFO"].to_s script_name = env['SCRIPT_NAME'] if path =~ self.class.match && rest = $1 env.merge! "SCRIPT_NAME"=>(script_name + self.class.path), "PATH_INFO"=>rest return @admin.call(env) else return @pass.call(env) end end