Class: Regurgitator::OneDomain
- Inherits:
-
Object
- Object
- Regurgitator::OneDomain
- Includes:
- Endpoint
- Defined in:
- lib/regurgitator/one_domain.rb
Overview
matches GET and HEAD requests in the format of “/:dkey” from a single, preconfigured domain.
If a client were to make a request to “example.com/bar”, this endpoint would respond with the file with the key “bar” from the preconfigured domain.
To use as middleware:
require 'regurgitator'
db = Sequel.connect('mysql2://[email protected]/mogilefs')
use Regurgitator::OneDomain, :domain => 'foo', :db => db
See the one_domain.ru example for a standalone app.
Instance Method Summary collapse
-
#call(env) ⇒ Object
:nodoc:.
-
#initialize(app, opts) ⇒ OneDomain
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) ⇒ OneDomain
:nodoc:
22 23 24 25 |
# File 'lib/regurgitator/one_domain.rb', line 22 def initialize(app, opts) # :nodoc: @domain = opts[:domain] endpoint_init(app, opts[:db], opts[:reproxy_key]) end |
Instance Method Details
#call(env) ⇒ Object
:nodoc:
27 28 29 30 31 32 33 34 |
# File 'lib/regurgitator/one_domain.rb', line 27 def call(env) # :nodoc: case env['REQUEST_METHOD'] when 'GET', 'HEAD' serve_file(env, @domain, env['PATH_INFO'][1..-1]) else @app.call(env) end end |