Sha256: 9e33bb62c7764fe85b69760d4ad314ce59feb40e55028fc77323083875382a6f

Contents?: true

Size: 637 Bytes

Versions: 6

Compression:

Stored size: 637 Bytes

Contents

module Grape
  class Request < Rack::Request
    def params
      @params ||= begin
        params = Hashie::Mash.new(super)
        if env['rack.routing_args']
          args = env['rack.routing_args'].dup
          # preserve version from query string parameters
          args.delete(:version)
          params.deep_merge!(args)
        end
        params
      end
    end

    def headers
      @headers ||= env.dup.inject({}) do |h, (k, v)|
        if k.to_s.start_with? 'HTTP_'
          k = k[5..-1].gsub('_', '-').downcase.gsub(/^.|[-_\s]./) { |x| x.upcase }
          h[k] = v
        end
        h
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
grape-security-0.8.0 lib/grape/http/request.rb
grape-0.10.1 lib/grape/http/request.rb
grape-0.10.0 lib/grape/http/request.rb
grape-0.9.0 lib/grape/http/request.rb
grape-0.8.0 lib/grape/http/request.rb
grape-0.7.0 lib/grape/http/request.rb