Class: Utter::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/utter/application.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/utter/application.rb', line 3

def call(env)
  req = Rack::Request.new(env)
  return [405, {"Allow" => 'POST', "Content-Type" => 'text/plain'}, "Not Acceptable"] unless req.post?
  
  if req.path_info =~ /^\/([a-z\d]+)$/
    site = Site[$1]
    if site
      site.regenerate
      return [200, {"Content-Type" => 'text/plain'}, "OK"]
    end
  end
        
  not_found
end

#not_foundObject



18
19
20
# File 'lib/utter/application.rb', line 18

def not_found
  return [404, {"Content-Type" => 'text/plain'}, "Not Found!\n"]
end