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