Class: Qdocs::Server
- Inherits:
-
Object
- Object
- Qdocs::Server
- Defined in:
- lib/qdocs/server.rb
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/qdocs/server.rb', line 5 def call(env) req = Rack::Request.new(env) params = req.params case env["REQUEST_PATH"] when "/" body = JSON.pretty_generate(Qdocs.lookup(params["input"])) [200, { "Content-Type" => "application/json; charset=utf-8" }, [body]] else [404, { "Content-Type" => "text/html; charset=utf-8" }, ["Not Found"]] end rescue => e [500, { "Content-Type" => "text/html; charset=utf-8" }, ["Error: #{e.}"]] end |