Slide 17
Slide 17 text
Do something
class Collector
Headers = {
html: { "Content-Type" => "text/html" },
json: { "Content-Type" => "application/json" },
}.freeze
def self.call(env)
req = Rack::Request.new(env)
api_key = env['hb.api_key']
case req.path_info
when “/v1/notices"
id = do_some_work(api_key, req)
render(%Q{{"id":"#{id}"}})
end
end
def self.render(body, headers = Headers[:json], status = 201)
[ status, headers, [ body ] ]
end
end