Skip to content

Commit

Permalink
Merge pull request #178 from zooniverse/update-api-to-return-410s
Browse files Browse the repository at this point in the history
update api to return 410s with error message to go to eras
  • Loading branch information
yuenmichelle1 authored Dec 18, 2023
2 parents 843a7d6 + 5d514f3 commit d47a913
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/api/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,19 @@ class Api < Sinatra::Base

register Sinatra::CrossOrigin

configure :production, :staging, :development do
enable :logging
set :search_client, Stats::Es::Client.new(:api)
set :elastic_search_client, Proc.new { settings.search_client.es_client }
end

get '/counts/?:type?/?:interval?\/?' do
cross_origin :allow_origin => cors_origins,
:allowmethods => [:get]
results = histogram_count
json format_results(results)
[410, json({ message: 'stats.zooniverse.org is now defunct in favor of our new stats service: eras.zooniverse.org. Please refer to ERAS API Docs: https://zooniverse.github.io/eras.' })]
end

get '/' do
json({ health: 'ok', revision: ENV['REVISION'] })
[410, json({ message: 'stats.zooniverse.org is now defunct in favor of our new stats service: eras.zooniverse.org. Please refer to ERAS API Docs: https://zooniverse.github.io/eras.' })]
end

# sinkhole 404 & 400 responses
error Sinatra::NotFound do
[404, json({ message: 'Not Found' })]
[404, json({ message: 'stats.zooniverse.org is now defunct in favor of our new stats service: eras.zooniverse.org. Please refer to ERAS API Docs: https://zooniverse.github.io/eras.' })]
end

error Sinatra::BadRequest do
Expand Down

0 comments on commit d47a913

Please sign in to comment.