Class: Regurgitator::DomainPath
- Inherits:
-
Object
- Object
- Regurgitator::DomainPath
- Includes:
- Endpoint
- Defined in:
- lib/regurgitator/domain_path.rb
Overview
matches GET and HEAD requests in the format of “/:namespace/:dkey” where :dkey
may contain multiple slashes
If a client were to make a request to “example.com/d/foo/bar”, this endpoint would respond with the file from the “d” domain with the key “foo/bar”.
To use as middleware:
require 'regurgitator'
db = Sequel.connect('mysql2://[email protected]/mogilefs')
use Regurgitator::DomainPath, db
See the domain_path.ru example for a standalone app.
Instance Method Summary collapse
-
#call(env) ⇒ Object
:nodoc:.
-
#initialize(app, opts) ⇒ DomainPath
constructor
:nodoc:.
Methods included from Endpoint
#best_addr, #empty_file, #endpoint_init, #filename!, #reproxy_path, #serve_file, #serve_info
Methods included from FileInfo
Methods included from Device
#device_init, #device_uris!, extended, #refresh_device, #refresh_device_unlocked
Methods included from ServerSettings
extended, #refresh_zone, #refresh_zone_unlocked, #server_settings_init, #zone_for
Methods included from Domain
#domain_init, #get_dmid, #refresh_domain, #refresh_domain_unlocked
Constructor Details
#initialize(app, opts) ⇒ DomainPath
:nodoc:
31 32 33 34 |
# File 'lib/regurgitator/domain_path.rb', line 31 def initialize(app, opts) # :nodoc: opts = { :db => opts } unless Hash === opts endpoint_init(app, opts[:db], opts[:reproxy_key]) end |
Instance Method Details
#call(env) ⇒ Object
:nodoc:
21 22 23 24 25 26 27 28 29 |
# File 'lib/regurgitator/domain_path.rb', line 21 def call(env) # :nodoc: case env['REQUEST_METHOD'] when 'GET', 'HEAD' env['PATH_INFO'] =~ %r{\A/([^/]+)/(.+)\z} or return @app.call(env) serve_file(env, $1, $2) else @app.call(env) end end |