aboutsummaryrefslogtreecommitdiffstats
path: root/spec/bundler/support/artifice/endpoint_fallback.rb
blob: 8a85a41784ed2723e1e1473f82fbcabccbfd7413 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true
require File.expand_path("../endpoint", __FILE__)

Artifice.deactivate

class EndpointFallback < Endpoint
  DEPENDENCY_LIMIT = 60

  get "/api/v1/dependencies" do
    if params[:gems] && params[:gems].size <= DEPENDENCY_LIMIT
      Marshal.dump(dependencies_for(params[:gems]))
    else
      halt 413, "Too many gems to resolve, please request less than #{DEPENDENCY_LIMIT} gems"
    end
  end
end

Artifice.activate_with(EndpointFallback)