diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-10 00:13:58 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-10 00:13:58 +0000 |
commit | 071a678a156dde974d8e470b659c89cb02b07b3b (patch) | |
tree | a0c846f48a5107c97261a117e7624edabe6feddd /lib/webrick/httpservlet/filehandler.rb | |
parent | 7e3ec1db0da950bf77bc3aa8d9b24b161cb60654 (diff) |
* lib/webrick: Add Documentation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/httpservlet/filehandler.rb')
-rw-r--r-- | lib/webrick/httpservlet/filehandler.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb index daad8abd27..263c9fc80f 100644 --- a/lib/webrick/httpservlet/filehandler.rb +++ b/lib/webrick/httpservlet/filehandler.rb @@ -125,17 +125,48 @@ module WEBrick end end + ## + # Serves files from a directory + class FileHandler < AbstractServlet HandlerTable = Hash.new + ## + # Allow custom handling of requests for files with +suffix+ by class + # +handler+ + def self.add_handler(suffix, handler) HandlerTable[suffix] = handler end + ## + # Remove custom handling of requests for files with +suffix+ + def self.remove_handler(suffix) HandlerTable.delete(suffix) end + ## + # Creates a FileHandler servlet on +server+ that serves files starting + # at directory +root+ + # + # If +options+ is a Hash the following keys are allowed: + # + # :AcceptableLanguages:: Array of languages allowed for accept-language + # :DirectoryCallback:: Allows preprocessing of directory requests + # :FancyIndexing:: If true, show an index for directories + # :FileCallback:: Allows preprocessing of file requests + # :HandlerCallback:: Allows preprocessing of requests + # :HandlerTable:: Maps file suffixes to file handlers. + # DefaultFileHandler is used by default but any servlet + # can be used. + # :NondisclosureName:: Do not show files matching this array of globs + # :UserDir:: Directory inside ~user to serve content from for /~user + # requests. Only works if mounted on / + # + # If +options+ is true or false then +:FancyIndexing+ is enabled or + # disabled respectively. + def initialize(server, root, options={}, default=Config::FileHandler) @config = server.config @logger = @config[:Logger] |