Class: Berkshelf::API::Endpoint::Base

Inherits:
Grape::API
  • Object
show all
Defined in:
lib/berkshelf/api/endpoint.rb

Direct Known Subclasses

V1, RackApp

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object

Force inbound requests to be JSON



8
9
10
11
12
13
# File 'lib/berkshelf/api/endpoint.rb', line 8

def call(env)
  env['CONTENT_TYPE'] = 'application/json'
  # If coming from a browser or other naive HTTP client, we want JSON back
  env['HTTP_ACCEPT'] = 'application/json' if !env['HTTP_ACCEPT'] || env['HTTP_ACCEPT'].include?('text/html')
  super
end