Sha256: 3c167c1b8887c2c81dc13d354c129fd23e98abe81931ab78070a2b8e15baf66f

Contents?: true

Size: 444 Bytes

Versions: 23

Compression:

Stored size: 444 Bytes

Contents

require 'faraday'



module Saddle
  module Middleware
    module Request

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

      class PathPrefix < Faraday::Middleware
        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
      end

    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
saddle-0.0.27 lib/saddle/middleware/request/path_prefix.rb
saddle-0.0.26 lib/saddle/middleware/request/path_prefix.rb
saddle-0.0.25 lib/saddle/middleware/request/path_prefix.rb