Module: Grape::DSL::Headers

Included in:
InsideRoute, Middleware::Base
Defined in:
lib/grape/dsl/headers.rb

Instance Method Summary collapse

Instance Method Details

#header(key = nil, val = nil) ⇒ Object Also known as: 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



11
12
13
14
15
16
17
# File 'lib/grape/dsl/headers.rb', line 11

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