diff options
author | gebele <gebele@in-silico.ch> | 2019-06-18 12:49:35 +0000 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2019-06-18 12:49:35 +0000 |
commit | 3869670b3acfb4de982f45ea24af940eccac5474 (patch) | |
tree | 6ad877b04260b252cd6af06014741cbd59928e56 /application.rb | |
parent | 091e0c3d84223bb7513c88cbac103d0aaee1a32c (diff) |
update routes and mime type and generate server uri for API file
Diffstat (limited to 'application.rb')
-rw-r--r-- | application.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/application.rb b/application.rb index a2ec091..87d676b 100644 --- a/application.rb +++ b/application.rb @@ -51,11 +51,14 @@ before do "substance", "swagger", "validation"] - if request.path.split("/")[1] == "api" || $paths.include?(request.path.split("/")[2]) + if request.path =~ /predict/ @accept = request.env['HTTP_ACCEPT'].split(",").first response['Content-Type'] = @accept - else + halt 400, "Mime type #{@accept} is not supported." unless @accept == "text/html" || "*/*" @version = File.read("VERSION").chomp + else + @accept = request.env['HTTP_ACCEPT'].split(",").first + response['Content-Type'] = @accept end end @@ -253,7 +256,7 @@ get '/prediction/:neighbor/details/?' do haml :details, :layout => false end -get '/license' do +get '/predict/license' do @license = RDiscount.new(File.read("LICENSE.md")).to_html haml :license, :layout => false end @@ -263,7 +266,7 @@ get '/predict/faq' do haml :faq#, :layout => false end -get '/help' do +get '/predict/help' do haml :help end @@ -273,7 +276,7 @@ get '/style.css' do end # for swagger representation -get '/swagger-ui.css' do +get '/api/swagger-ui.css' do headers 'Content-Type' => 'text/css; charset=utf-8' scss :style end |