Sha256: 271474df7bfdfb7bd79b7813460e739eacf8db0e818232c903f533f6aa0ff885

Contents?: true

Size: 932 Bytes

Versions: 6

Compression:

Stored size: 932 Bytes

Contents

# -*- encoding: binary -*-

# matches GET and HEAD requests in the format of "/:dkey" from a
# single, preconfigured domain.
#
# If a client were to make a request to "http://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://user@example.com/mogilefs')
#    use Regurgitator::OneDomain, :domain => 'foo', :db => db
#
# See the {one_domain.ru}[link:examples/one_domain.ru]
# example for a standalone app.
class Regurgitator::OneDomain
  include Regurgitator::Endpoint

  def initialize(app, opts) # :nodoc:
    @domain = opts[:domain]
    endpoint_init(app, opts[:db], opts[:reproxy_key])
  end

  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
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
regurgitator-0.7.0 lib/regurgitator/one_domain.rb
regurgitator-0.6.0 lib/regurgitator/one_domain.rb
regurgitator-0.5.0 lib/regurgitator/one_domain.rb
regurgitator-0.4.0 lib/regurgitator/one_domain.rb
regurgitator-0.3.0 lib/regurgitator/one_domain.rb
regurgitator-0.2.0 lib/regurgitator/one_domain.rb