Sha256: 3fb5ab99cceb67847966a6d3138f7520253ddd2092b4603c79759cfc6ea83d5c

Contents?: true

Size: 564 Bytes

Versions: 5

Compression:

Stored size: 564 Bytes

Contents

# frozen_string_literal: true

module Grape
  module DSL
    module Headers
      # This method has four responsibilities:
      # 1. Set a specifc header value by key
      # 2. Retrieve a specifc header value by key
      # 3. Retrieve all headers that have been set
      # 4. Delete a specifc header key-value pair
      def header(key = nil, val = nil)
        if key
          val ? header[key.to_s] = val : header.delete(key.to_s)
        else
          @header ||= Grape::Util::Header.new
        end
      end
      alias headers header
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grape-2.2.0 lib/grape/dsl/headers.rb
grape-2.1.3 lib/grape/dsl/headers.rb
grape-2.1.2 lib/grape/dsl/headers.rb
grape-2.1.1 lib/grape/dsl/headers.rb
grape-2.1.0 lib/grape/dsl/headers.rb