Sha256: 4adfea742fa51a43fd5537ee93ddad962db5de37e2381b3cd32c8a3ebaf5cc01
Contents?: true
Size: 491 Bytes
Versions: 2
Compression:
Stored size: 491 Bytes
Contents
class Simple::Httpd::App::FileServer # A simple file server middleware def initialize(app, url_prefix:, root:) @app = app @url_prefix = File.join("/", url_prefix, "/") @file_server = Rack::File.new(root) end def call(env) request_path = env["PATH_INFO"] if request_path.start_with?(@url_prefix) file_path = request_path[@url_prefix.length..-1] env["PATH_INFO"] = file_path @file_server.call(env) else @app.call(env) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple-httpd-0.0.4 | lib/simple/httpd/app/file_server.rb |
simple-httpd-0.0.2 | lib/simple/httpd/app/file_server.rb |