summaryrefslogtreecommitdiff
path: root/lib/api.rb
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2018-06-11 12:46:06 +0200
committergebele <gebele@in-silico.ch>2018-06-11 12:46:06 +0200
commit3a11ba2918795821600b7113d0758415718d263a (patch)
tree2c03bdf1ed63582b8bb865c858ce225dee791a34 /lib/api.rb
parent409c8a5a353235c91cbf965a885dd12da699d993 (diff)
combine gui with rest
Diffstat (limited to 'lib/api.rb')
-rw-r--r--lib/api.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/api.rb b/lib/api.rb
new file mode 100644
index 0000000..28e33df
--- /dev/null
+++ b/lib/api.rb
@@ -0,0 +1,9 @@
+# route to swagger API file
+get "/api/api.json" do
+ response['Content-Type'] = "application/json"
+ api_file = File.join("api", "api.json")
+ bad_request_error "API Documentation in Swagger JSON is not implemented." unless File.exists?(api_file)
+ api_hash = JSON.parse(File.read(api_file))
+ api_hash["host"] = request.env['HTTP_HOST']
+ return api_hash.to_json
+end