Sha256: 07a98e5b03f1bee842fbf3bbbabda95ee5e53e55b2a34e681e2721cbc0606fe4

Contents?: true

Size: 430 Bytes

Versions: 1

Compression:

Stored size: 430 Bytes

Contents

module Rad
  class StaticFiles

    def initialize(app, dir, filter = nil)
      @app = app
      @dir = File.expand_path(dir)
      @file_server = Rack::File.new(@dir)
      @filter = filter
    end

    def call(env)
      path = env["PATH_INFO"]

      if (!@filter or (@filter and @filter =~ path)) and File.exist?("#{@dir}#{path}")
        @file_server.call(env)
      else
        @app.call(env)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rad_core-0.0.13 lib/rad/http/middleware/static_files.rb