Class: CgnsSearch

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/cgns_search.rb

Constant Summary collapse

ALLOWED_PARAMS =
%w(geoname)

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cgns_search.rb', line 12

def call(env)
  request = Rack::Request.new(env)

  headers = { "Content-Type" => "application/json" }
  begin
    response = Rack::Response.new(find(request.params), 200, headers)      
    # set caching information
    response.headers['Cache-Control'] = "public, max-age=#{1.week}"
  rescue Exception => e
    response = Rack::Response.new({ :error => e.message }.to_json, 500, headers)
  end
  
  response.to_a
end