Method: Grape::DSL::InsideRoute#body

Defined in:
lib/grape/dsl/inside_route.rb

#body(value = nil) ⇒ Object

Allows you to define the response body as something other than the return value.

Examples:

get '/body' do
  body "Body"
  "Not the Body"
end

GET /body # => "Body"


110
111
112
113
114
115
116
117
118
119
# File 'lib/grape/dsl/inside_route.rb', line 110

def body(value = nil)
  if value
    @body = value
  elsif value == false
    @body = ''
    status 204
  else
    instance_variable_defined?(:@body) ? @body : nil
  end
end