lib/dragonfly/server.rb in dragonfly-0.9.12 vs lib/dragonfly/server.rb in dragonfly-0.9.13
- old
+ new
@@ -4,32 +4,32 @@
# Exceptions
class JobNotAllowed < RuntimeError; end
include Loggable
include Configurable
-
+
configurable_attr :allow_fetch_file, false
configurable_attr :allow_fetch_url, false
configurable_attr :dragonfly_url, '/dragonfly'
configurable_attr :protect_from_dos_attacks, false
configurable_attr :url_format, '/:job/:basename.:format'
configurable_attr :url_host
extend Forwardable
def_delegator :url_mapper, :params_in_url
-
+
def initialize(app)
@app = app
use_same_log_as(app)
use_as_fallback_config(app)
end
-
+
def before_serve(&block)
self.before_serve_callback = block
end
configuration_method :before_serve
-
+
def call(env)
if dragonfly_url == env["PATH_INFO"]
dragonfly_response
elsif (params = url_mapper.params_for(env["PATH_INFO"], env["QUERY_STRING"])) && params['job']
job = Job.deserialize(params['job'], app)
@@ -66,16 +66,15 @@
url = url_mapper.url_for(params)
"#{host}#{url}"
end
private
-
+
attr_reader :app
attr_accessor :before_serve_callback
def url_mapper
@url_mapper ||= UrlMapper.new(url_format,
- :job => '[\w+~]',
:basename => '[^\/]',
:name => '[^\/]',
:format => '[^\.]'
)
end