Sha256: acf19f9d4ed567bb24833aad6a1e6f5d8882f6c5616e2576e98705324fb92228

Contents?: true

Size: 552 Bytes

Versions: 6

Compression:

Stored size: 552 Bytes

Contents

require 'sinatra/base'
require 'animal_service/animal_repository'

module AnimalService

  class Api < Sinatra::Base

    set :raise_errors, false
    set :show_exceptions, false

    error do
      e = env['sinatra.error']
      content_type :json
      status 500
      {error: e.message, backtrace: e.backtrace}.to_json
    end

    get '/alligators/:name' do
      if (alligator = AnimalRepository.find_alligator_by_name(params[:name]))
        content_type :json
        alligator.to_json
      else
        status 404
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pact-1.2.1.rc1 example/animal-service/lib/animal_service/api.rb
pact-1.1.1 example/animal-service/lib/animal_service/api.rb
pact-1.1.0 example/animal-service/lib/animal_service/api.rb
pact-1.1.0.rc5 example/animal-service/lib/animal_service/api.rb
pact-1.1.0.rc4 example/animal-service/lib/animal_service/api.rb
pact-1.1.0.rc3 example/animal-service/lib/animal_service/api.rb