Sha256: 12276343a1d39d7c2fe9ebf5218747e36e1cbe7d199f8cd54894b0711524c14d

Contents?: true

Size: 1.94 KB

Versions: 2

Compression:

Stored size: 1.94 KB

Contents

module Rack::App::Constants

  require "rack/app/constants/http_status_codes"

  def self.rack_constant(constant_name, fallback_value)
    ::Rack.const_get(constant_name)
  rescue NameError
    fallback_value.freeze
  end

  module HTTP

    module METHOD
      ANY     = 'ANY'.freeze
      GET     = 'GET'.freeze
      POST    = 'POST'.freeze
      PUT     = 'PUT'.freeze
      PATCH   = 'PATCH'.freeze
      DELETE  = 'DELETE'.freeze
      HEAD    = 'HEAD'.freeze
      OPTIONS = 'OPTIONS'.freeze
      LINK    = 'LINK'.freeze
      UNLINK  = 'UNLINK'.freeze
      TRACE   = 'TRACE'.freeze
    end

    METHODS = (METHOD.constants - [:ANY]).map(&:to_s).freeze

    module Headers
      CONTENT_TYPE = "Content-Type".freeze
    end

  end

  module ENV

    PATH_INFO = Rack::App::Constants.rack_constant(:PATH_INFO, "PATH_INFO")
    REQUEST_PATH = Rack::App::Constants.rack_constant(:REQUEST_PATH, "REQUEST_PATH")
    REQUEST_METHOD = Rack::App::Constants.rack_constant(:REQUEST_METHOD, "REQUEST_METHOD")

    ROUTER = 'rack-app.router'.freeze
    EXTNAME = 'rack-app.extname'.freeze
    SERIALIZER = 'rack-app.serializer'.freeze
    CONTENT_TYPE = 'CONTENT_TYPE'.freeze
    REQUEST_HANDLER = 'rack-app.handler'.freeze

    PARAMS_GETTER = 'rack-app.params.getter'
    PARSED_PARAMS = 'rack-app.params.parsed'.freeze
    VALIDATED_PARAMS = 'rack-app.params.validated'.freeze

    PAYLOAD_PARSER = 'rack-app.payload.parser'.freeze
    PAYLOAD_GETTER = 'rack-app.payload.getter'.freeze
    PARSED_PAYLOAD = 'rack-app.payload.parsed'.freeze

    PATH_PARAMS = 'rack-app.path_params'.freeze
    ORIGINAL_PATH_INFO = 'rack-app.original_path_info'.freeze
    FORMATTED_PATH_INFO = 'rack-app.formatted_path_info'.freeze
    SPLITTED_PATH_INFO = 'rack-app.splitted_path_info'.freeze
    METHODOVERRIDE_ORIGINAL_METHOD = 'rack-app.methodoverride.original_method'.freeze

  end

  module PATH
    MOUNT_POINT = "[MOUNT_POINT]".freeze
    APPLICATION = "[Mounted Application]".freeze
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-app-6.0.0 lib/rack/app/constants.rb
rack-app-5.12.0 lib/rack/app/constants.rb