Sha256: f7d41dd1665a34d2aa9c863a854a5dc280c96ff11a84aef64833ac49bdf9bc48

Contents?: true

Size: 566 Bytes

Versions: 2

Compression:

Stored size: 566 Bytes

Contents

# frozen_string_literal: true

module BridgetownPluginNano
  module Middleware
    class NotFound
      def initialize(app, path, content_type = "text/html; charset=utf-8")
        @app = app
        @content = File.read(path)
        @length = @content.bytesize.to_s
        @content_type = content_type
      end

      def call(env)
        response = @app.call(env)
        if response[0] == 404
          [404, { "Content-Type" => @content_type, "Content-Length" => @length }, [@content]]
        else
          response
        end
      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/not_found.rb
bridgetown-plugin-nano-0.2.0 lib/bridgetown-plugin-nano/rack_middleware/not_found.rb