class WEBrick::HTTPServlet::FileHandler
Serves a directory including fancy indexing and a variety of other options.
Example:
server.mount('/assets', WEBrick::HTTPServlet::FileHandler, '/path/to/assets')
Public Class Methods
(String suffix, singleton(AbstractServlet) handler) → singleton(AbstractServlet)
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/lib/webrick/httpservlet/filehandler.rb, line 182 def self.add_handler(suffix, handler) HandlerTable[suffix] = handler end
Allow custom handling of requests for files with suffix by class handler
(HTTPServer server, String root, ?Hash[Symbol, untyped] options, ?Hash[Symbol, untyped] default) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/lib/webrick/httpservlet/filehandler.rb, line 203 def initialize(server, root, options={}, default=Config::FileHandler) @config = server.config @logger = @config[:Logger] @root = File.expand_path(root) if options == true || options == false options = { :FancyIndexing => options } end @options = default.dup.update(options) end
Creates a FileHandler servlet on server that serves files starting at directory root
options may be a Hash containing keys from WEBrick::Config::FileHandler or true or false.
If options is true or false then :FancyIndexing is enabled or disabled respectively.
(String suffix) → singleton(AbstractServlet)
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/lib/webrick/httpservlet/filehandler.rb, line 189 def self.remove_handler(suffix) HandlerTable.delete(suffix) end
Remove custom handling of requests for files with suffix
Public Instance Methods
(Symbol callback_name, HTTPRequest req, HTTPResponse res) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 67
def call_callback: (Symbol callback_name, HTTPRequest req, HTTPResponse res) -> void
(HTTPRequest req, HTTPResponse res, String name) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 59
def check_filename: (HTTPRequest req, HTTPResponse res, String name) -> void
(HTTPRequest req, HTTPResponse res) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 41
def do_GET: (HTTPRequest req, HTTPResponse res) -> void
(HTTPRequest req, HTTPResponse res) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 45
def do_OPTIONS: (HTTPRequest req, HTTPResponse res) -> void
(HTTPRequest req, HTTPResponse res) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 43
def do_POST: (HTTPRequest req, HTTPResponse res) -> void
(HTTPRequest req, HTTPResponse res) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 53
def exec_handler: (HTTPRequest req, HTTPResponse res) -> bool
(HTTPRequest req, HTTPResponse res) → singleton(AbstractServlet)
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 55
def get_handler: (HTTPRequest req, HTTPResponse res) -> singleton(AbstractServlet)
(String name) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 71
def nondisclosure_name?: (String name) -> bool
(HTTPRequest req, HTTPResponse res) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 51
def prevent_directory_traversal: (HTTPRequest req, HTTPResponse res) -> void
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 65
def search_file: (HTTPRequest req, HTTPResponse res, String basename) -> String?
(HTTPRequest req, HTTPResponse res) → String?
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 63
def search_index_file: (HTTPRequest req, HTTPResponse res) -> String?
(HTTPRequest req, HTTPResponse res) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 39
def service: (HTTPRequest req, HTTPResponse res) -> void
(HTTPRequest req, HTTPResponse res) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 73
def set_dir_list: (HTTPRequest req, HTTPResponse res) -> void
(HTTPRequest req, HTTPResponse res) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 57
def set_filename: (HTTPRequest req, HTTPResponse res) -> bool
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 37
def set_filesystem_encoding: (String str) -> String
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 61
def shift_path_info: (HTTPRequest req, HTTPResponse res, String path_info, ?String? base) -> void
(String path) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 49
def trailing_pathsep?: (String path) -> bool
(String name) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/sig/httpservlet/filehandler.rbs, line 69
def windows_ambiguous_name?: (String name) -> bool