class Vienna::Static

`Vienna::Static` is just a wrapper for `Rack::Static` with sane and opinionated options.

It serves all files under the given `root` and doesn't passes on requests for files that don't exist.

Examples

use Vienna::Static, 'public'

Public Class Methods

new(app, root) click to toggle source
# File lib/vienna.rb, line 35
def initialize(app, root)
  @app = app
  @root = root
end

Public Instance Methods

call(env) click to toggle source
# File lib/vienna.rb, line 60
def call(env)
  Rack::Static.new(@app, options).call(env)
end
header_rules() click to toggle source
# File lib/vienna.rb, line 52
def header_rules
  [[:all, {'Cache-Control' => 'public, max-age=3600'}]]
end
index() click to toggle source
# File lib/vienna.rb, line 48
def index
  'index.html'
end
options() click to toggle source
# File lib/vienna.rb, line 56
def options
  {urls: urls, root: root, index: index, header_rules: header_rules}
end
root() click to toggle source
# File lib/vienna.rb, line 44
def root
  @root
end
urls() click to toggle source
# File lib/vienna.rb, line 40
def urls
  Dir.glob("#{root}/*").map { |f| f.sub(root, '') }
end