diff options
author | gebele <gebele@in-silico.ch> | 2018-07-05 10:38:55 +0000 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2018-07-05 10:38:55 +0000 |
commit | 878f014ec6cc808af99af5045bcc1a1143cab8d9 (patch) | |
tree | 38458f73295d58c2ab487c81056d0abf0e4c4c19 /lib/endpoint.rb | |
parent | 395506ca3fe4daa5689fd197e57f7ab944beb1d7 (diff) |
updated with endpoint list; refined error handling; refined prediction input
Diffstat (limited to 'lib/endpoint.rb')
-rw-r--r-- | lib/endpoint.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/endpoint.rb b/lib/endpoint.rb new file mode 100644 index 0000000..ef39787 --- /dev/null +++ b/lib/endpoint.rb @@ -0,0 +1,23 @@ +# 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 + models = Model::Validation.all + endpoints = models.collect{|m| m.endpoint}.uniq + case @accept + when "text/uri-list" + return endpoints.join("\n") + "\n" + when "application/json" + return endpoints.to_json + else + bad_request_error "Mime type #{@accept} is not supported." + end +end + +get "/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? + return list.to_json +end |