Method: WebFacter::App#call

Defined in:
lib/web-facter.rb

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/web-facter.rb', line 14

def call(env)
  response = Rack::Response.new
  response.header['Content-Type'] = 'application/json'
  facts = Facter.to_hash.dup
  @filters.each do |filter|
    facts.delete(filter.strip)
  end
  response.write JSON.pretty_generate(facts)
  response.finish
end