Class: BetterAuth::Sinatra::MountedApp

Inherits:
Object
  • Object
show all
Defined in:
lib/better_auth/sinatra/mounted_app.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, auth, mount_path:) ⇒ MountedApp

Returns a new instance of MountedApp.



6
7
8
9
10
# File 'lib/better_auth/sinatra/mounted_app.rb', line 6

def initialize(app, auth, mount_path:)
  @app = app
  @auth = auth
  @mount_path = normalize_path(mount_path)
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/better_auth/sinatra/mounted_app.rb', line 12

def call(env)
  return @app.call(env) unless mount_matches?(env)

  rewritten_path = mounted_path_info(env)
  next_env = env.merge("PATH_INFO" => rewritten_path)
  next_env["SCRIPT_NAME"] = "" if shared_mount_rewrite?(env, rewritten_path)
  auth.call(next_env)
end