Sha256: 821563c10517b7e666031b4cac8259e8e6a5a3c3e5710a47519f8ac2212891b4

Contents?: true

Size: 595 Bytes

Versions: 8

Compression:

Stored size: 595 Bytes

Contents

require 'grape'
require 'grape-msgpack'

module Berkshelf::API
  module Endpoint
    class Base < Grape::API
      # Force inbound requests to be JSON
      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
    end
  end
end

Dir["#{File.dirname(__FILE__)}/endpoint/*.rb"].sort.each do |path|
  require "berkshelf/api/endpoint/#{File.basename(path, '.rb')}"
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
berkshelf-api-3.0.0 lib/berkshelf/api/endpoint.rb
berkshelf-api-2.2.0 lib/berkshelf/api/endpoint.rb
berkshelf-api-2.1.3 lib/berkshelf/api/endpoint.rb
berkshelf-api-2.1.2 lib/berkshelf/api/endpoint.rb
berkshelf-api-2.1.1 lib/berkshelf/api/endpoint.rb
berkshelf-api-2.1.0 lib/berkshelf/api/endpoint.rb
berkshelf-api-2.0.0 lib/berkshelf/api/endpoint.rb
berkshelf-api-1.4.0 lib/berkshelf/api/endpoint.rb