Class: Saddle::Middleware::Request::PathPrefix

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/saddle/middleware/request/path_prefix.rb

Overview

Public: Adds a prefix to the relative url path if present

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/saddle/middleware/request/path_prefix.rb', line 12

def call(env)
  if env[:request][:client_options][:path_prefix]
    env[:url].path = "/#{env[:request][:client_options][:path_prefix]}#{env[:url].path}"
  end

  @app.call env
end