Class: Syntropy::Markdown::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/syntropy/markdown.rb

Instance Method Summary collapse

Constructor Details

#initialize(env, atts, md) ⇒ Controller

Returns a new instance of Controller.



16
17
18
19
20
21
# File 'lib/syntropy/markdown.rb', line 16

def initialize(env, atts, md)
  @env = env
  @atts = atts
  @md = md
  @module_loader = env[:module_loader]
end

Instance Method Details

#to_procObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/syntropy/markdown.rb', line 23

def to_proc
  ->(req) {
    case req.method
    when 'head'
      req.respond_html(nil)
    when 'get'
      md = process_md_embeds
      html = render(md)
      req.respond_html(html)
    else
      req.respond(nil, ':status' => HTTP::METHOD_NOT_ALLOWED)
    end
  }
end