Sha256: 67f3d575f494e5e7ac4a0910eb1a8f0f096a727449954cd7fa5ccfb20088a75f

Contents?: true

Size: 675 Bytes

Versions: 3

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true

require 'request_store'

# request helpers
module RequestHelpers
  extend Grape::API::Helpers

  def http_request_id
    RequestStore.store[:http_request_id]
  end

  def input_data
    env[Grape::Env::API_REQUEST_BODY]
  end

  # Get accept-language
  def accept_language
    available = ::LOCALE_LIST if defined? ::LOCALE_LIST
    env.http_accept_language.compatible_language_from(available)
  end

  def client_ip
    request.env['HTTP_X_FORWARDED_FOR'] || request.env['REMOTE_ADDR'] || '0.0.0.0'
  end

  def user_agent
    request.env['HTTP_USER_AGENT'] || 'unknown'
  end

  def route_desc
    route_setting(:description) || {}
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
svcbase-0.1.18 lib/svcbase/api/requesthelpers.rb
svcbase-0.1.17 lib/svcbase/api/requesthelpers.rb
svcbase-0.1.16 lib/svcbase/api/requesthelpers.rb