Class: Jacana::JacanaHttpServer

Inherits:
HTTPServer
  • Object
show all
Defined in:
lib/jacana.rb

Instance Method Summary collapse

Constructor Details

#initialize(*arg) ⇒ JacanaHttpServer

Returns a new instance of JacanaHttpServer.



10
11
12
13
14
15
16
17
18
19
# File 'lib/jacana.rb', line 10

def initialize *arg
  @rewrite_rules = []
  super
  i = {
      :Doc_Root => :Doc_Root,
      :indexing => true,
      :handlerTable => {'php' => WEBrick::HTTPServlet::Jacana::PHPHandler}
  }
  mountServer i
end

Instance Method Details

#a_rewrite(pattern, subst) ⇒ Object



26
27
28
# File 'lib/jacana.rb', line 26

def a_rewrite pattern, subst
  @rewrite_rules << [pattern, subst]
end

#jacana_services(req, res) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/jacana.rb', line 30

def jacana_services req, res
  path = req.path
  @rewrite_rules.each do |pattern, subst|
    if pattern =~ path
      new_path = path.gsub pattern, subst
      req.instance_variable_set "@path", new_path
      break
    end
  end
  super req, res
end

#mountServer(info) ⇒ Object



21
22
23
# File 'lib/jacana.rb', line 21

def mountServer(info)
  mount '/', WEBrick::HTTPServlet::FileHandler, config[:Doc_Root], :FancyIndexing => info[:indexing], :HandlerTable => info[:handlerTable]
end