Sha256: 5ea05b8f802363a899b2e8ea76358bd79a9b9b02ad920b16560358bbe0230b94

Contents?: true

Size: 935 Bytes

Versions: 5

Compression:

Stored size: 935 Bytes

Contents

module Rasti
  module Web
    module ApiDoc
      class Request

        def initialize(env)
          @env = env
        end

        def method
          env['REQUEST_METHOD']
        end

        def path_info
          env['PATH_INFO']
        end

        def route
          env['PATH_INFO'].dup.tap do |path_info|
            route_params.each do |name, value|
              path_info.sub! value, ":#{name}"
            end
          end
        end

        def route_params
          env['rack.request.route_params'] || {}
        end

        def query_params
          env['rack.request.query_hash'] || {}
        end

        def form_params
          env['rack.request.form_hash'] || {}
        end

        def headers
          {}.tap do |hash|
            hash['Content-Type'] = env['CONTENT_TYPE'] if env['CONTENT_TYPE']
          end
        end

        private

        attr_reader :env

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rasti-web-api_doc-1.0.1 lib/rasti/web/api_doc/request.rb
rasti-web-api_doc-1.0.0 lib/rasti/web/api_doc/request.rb
rasti-web-api_doc-0.1.2 lib/rasti/web/api_doc/request.rb
rasti-web-api_doc-0.1.1 lib/rasti/web/api_doc/request.rb
rasti-web-api_doc-0.1.0 lib/rasti/web/api_doc/request.rb