Class: Bard::Api::App

Inherits:
Object
  • Object
show all
Defined in:
lib/bard/api/app.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bard/api/app.rb', line 11

def call(env)
  request = Rack::Request.new(env)
  method = request.request_method
  path = request.path_info

  case [method, path]
  when ["GET", "/health"]
    health(request)
  when ["POST", "/backups"]
    create_backup(request)
  when ["GET", "/backups/latest"]
    latest_backup(request)
  when ["GET", "/config"]
    config(request)
  else
    not_found
  end
rescue => e
  json_response(500, { error: e.message })
end