Sha256: c5c6591cd512cd59caf4c8ac6e4ad76c697c56d8d8b00aedfbda91928a7a36d2
Contents?: true
Size: 817 Bytes
Versions: 2
Compression:
Stored size: 817 Bytes
Contents
# frozen_string_literal: true module BridgetownPluginNano module Middleware # Based on Rack::TryStatic middleware # https://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/try_static.rb class Static def initialize(app, options) @app = app @try = ["", ".html", "index.html", "/index.html", *options[:try]] @static = Rack::Static.new( ->(_) { [404, {}, []] }, options ) end def call(env) orig_path = env["PATH_INFO"] found = nil @try.each do |path| resp = @static.call(env.merge!({ "PATH_INFO" => orig_path + path })) break if !(403..405).cover?(resp[0]) && (found = resp) end found || @app.call(env.merge!("PATH_INFO" => orig_path)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bridgetown-plugin-nano-0.2.1 | lib/bridgetown-plugin-nano/rack_middleware/static.rb |
bridgetown-plugin-nano-0.2.0 | lib/bridgetown-plugin-nano/rack_middleware/static.rb |