Module: Useless::Doc::Proxy::HTML

Defined in:
lib/useless/doc/proxy/html.rb

Overview

Doc::Proxy::HTML is the base application for Useless::Doc::Proxy. It expects a Doc::UI instance to be set as ‘useless.doc.ui’, and a Doc::Core entity to be set as ‘useless.doc.subject’, and then simply passes the latter to the former’s #html method.

Class Method Summary collapse

Class Method Details

.call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/useless/doc/proxy/html.rb', line 11

def self.call(env)
  if html = env['useless.doc.ui'].html(env['useless.doc.subject'])
    if env['useless.doc.logger']
      env['useless.doc.logger'].info "rendered subject HTML for #{env['useless.doc.url']}"
      env['useless.doc.logger'].debug "rendered HTML: #{html}"
    end

    [200, {'Content-Type' => 'text/html'}, [html]]
  else
    [404, {'Content-Type' => 'text/plain'}, ['Could not render documentation.']]
  end
end