Sha256: fbb35b7523a35ce0f661d479c8c3a0aebd917a357f7ce1ffc1e952050e8e36ed

Contents?: true

Size: 353 Bytes

Versions: 3

Compression:

Stored size: 353 Bytes

Contents

module Crystal
  class StaticFiles

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

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

      if File.exist? "#{@root}#{path}"
        @file_server.call(env)
      else
        @app.call(env)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
crystal-0.0.13 lib/crystal/http/middleware/static_files.rb
crystal-0.0.12 lib/crystal/http/middleware/static_files.rb
crystal_ext-0.0.11 lib/crystal/http/middleware/static_files.rb