Sha256: 1c71ae03009f12b298c5b42eab4b6e75da6196696739882788ab54a656565c6b

Contents?: true

Size: 962 Bytes

Versions: 12

Compression:

Stored size: 962 Bytes

Contents

require "jacana/version"
require 'webrick'
require 'jacana/server'

module Jacana
  include WEBrick
  class JacanaHttpServer < HTTPServer


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

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


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

    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
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
jacana-0.1.2 lib/jacana.rb
jacana-0.1.1 lib/jacana.rb
jacana-0.1.0 lib/jacana.rb
jacana-0.0.9 lib/jacana.rb
jacana-0.0.8 lib/jacana.rb
jacana-0.0.7 lib/jacana.rb
jacana-0.0.6 lib/jacana.rb
jacana-0.0.5 lib/jacana.rb
jacana-0.0.4 lib/jacana.rb
jacana-0.0.3 lib/jacana.rb
jacana-0.0.2 lib/jacana.rb
jacana-0.0.1 lib/jacana.rb