Sha256: 4ab2cbc2a5871788a792f5453bff5a044f310af16f0667477a274abd12dc0138

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 Bytes

Contents

module Grape
  class Request < Rack::Request

    def params
      @env['grape.request.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
      @env['grape.request.headers'] ||= @env.dup.inject({}) { |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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-0.5.0 lib/grape/http/request.rb