Class: BetterAuth::Grape::MountedApp

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

Instance Method Summary collapse

Constructor Details

#initialize(auth, mount_path:) ⇒ MountedApp

Returns a new instance of MountedApp.



8
9
10
11
# File 'lib/better_auth/grape/mounted_app.rb', line 8

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

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/better_auth/grape/mounted_app.rb', line 13

def call(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)
rescue BetterAuth::APIError, JSON::ParserError
  raise
rescue => error
  handle_unexpected_error(error, env)
end