lib/roda/plugins/public.rb in roda-3.1.0 vs lib/roda/plugins/public.rb in roda-3.2.0
- old
+ new
@@ -43,11 +43,15 @@
# :gzip :: Whether to serve already gzipped files with a .gz extension for clients
# supporting gzipped transfer encoding.
# :headers :: A hash of headers to use for statically served files
# :root :: Use this option for the root of the public directory (default: "public")
def self.configure(app, opts={})
- root = app.expand_path(opts[:root]||"public")
- app.opts[:public_server] = ::Rack::File.new(root, opts[:headers]||{}, opts[:default_mime] || 'text/plain')
+ if opts[:root]
+ app.opts[:public_root] = app.expand_path(opts[:root])
+ elsif !app.opts[:public_root]
+ app.opts[:public_root] = app.expand_path("public")
+ end
+ app.opts[:public_server] = ::Rack::File.new(app.opts[:public_root], opts[:headers]||{}, opts[:default_mime] || 'text/plain')
app.opts[:public_gzip] = opts[:gzip]
end
module RequestMethods
# Serve files from the public directory if the file exists and this is a GET request.