Class: Apiif::Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/apiif.rb

Instance Method Summary collapse

Instance Method Details

#serve_file(path, verb) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/apiif.rb', line 9

def serve_file(path, verb)
  path = File.join(Apiif::OPTIONS[:root], path, "#{verb}.json")

  if !File.exists?(path)
    halt 405 if Dir.exists?(File.dirname(path))
    halt 404
  end

  content_type :json
  File.read(path)
end