class Grape::Request

Constants

HTTP_PREFIX

Public Class Methods

new(env, **options) click to toggle source
Calls superclass method
# File lib/grape/request.rb, line 9
def initialize(env, **options)
  extend options[:build_params_with] || Grape.config.param_builder
  super(env)
end

Public Instance Methods

headers() click to toggle source
# File lib/grape/request.rb, line 22
def headers
  @headers ||= build_headers
end
params() click to toggle source
# File lib/grape/request.rb, line 14
def params
  @params ||= build_params
rescue EOFError
  raise Grape::Exceptions::EmptyMessageBody.new(content_type)
rescue Rack::Multipart::MultipartPartLimitError
  raise Grape::Exceptions::TooManyMultipartFiles.new(Rack::Utils.multipart_part_limit)
end
Also aliased as: rack_params
rack_params()
Alias for: params

Private Instance Methods

build_headers() click to toggle source
# File lib/grape/request.rb, line 36
def build_headers
  Grape::Util::Lazy::Object.new do
    env.each_pair.with_object(Grape::Util::Header.new) do |(k, v), headers|
      next unless k.to_s.start_with? HTTP_PREFIX

      transformed_header = Grape::Http::Headers::HTTP_HEADERS[k] || transform_header(k)
      headers[transformed_header] = v
    end
  end
end
grape_routing_args() click to toggle source
# File lib/grape/request.rb, line 28
def grape_routing_args
  args = env[Grape::Env::GRAPE_ROUTING_ARGS].dup
  # preserve version from query string parameters
  args.delete(:version)
  args.delete(:route_info)
  args
end
transform_header(header) click to toggle source
# File lib/grape/request.rb, line 47
def transform_header(header)
  -header[5..].tr('_', '-').downcase
end