diff options
author | gebele <gebele@in-silico.ch> | 2019-06-13 15:28:59 +0000 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2019-06-13 15:28:59 +0000 |
commit | 741701df8ff0861b3607a30e9aaf8b8a0c303cdf (patch) | |
tree | 40fd2c6ca4eb85f3077859d9a808d01ec5aa8ece /lib/endpoint.rb | |
parent | f37f0b654b36b66c133755c01f033859c35197f6 (diff) |
update with API
Diffstat (limited to 'lib/endpoint.rb')
-rw-r--r-- | lib/endpoint.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/endpoint.rb b/lib/endpoint.rb index ef39787..66b7ab2 100644 --- a/lib/endpoint.rb +++ b/lib/endpoint.rb @@ -1,7 +1,7 @@ # Get a list of all endpoints # @param [Header] Accept one of text/uri-list, # @return [text/uri-list] list of all prediction models -get "/endpoint/?" do +get "/api/endpoint/?" do models = Model::Validation.all endpoints = models.collect{|m| m.endpoint}.uniq case @accept @@ -10,14 +10,14 @@ get "/endpoint/?" do when "application/json" return endpoints.to_json else - bad_request_error "Mime type #{@accept} is not supported." + halt 400, "Mime type #{@accept} is not supported." end end -get "/endpoint/:endpoint/?" do +get "/api/endpoint/:endpoint/?" do models = Model::Validation.where(endpoint: params[:endpoint]) list = [] - models.each{|m| list << {m.species => uri("/model/#{m.id}")} } - not_found_error "Endpoint: #{params[:endpoint]} not found." if models.blank? + models.each{|m| list << {m.species => uri("/api/model/#{m.id}")} } + halt 404, "Endpoint: #{params[:endpoint]} not found." if models.blank? return list.to_json end |