Sha256: 3d0e30941d1a434dc39fab778b049f2e4242eb89911a0a0e1ae710aea90c1f24

Contents?: true

Size: 427 Bytes

Versions: 4

Compression:

Stored size: 427 Bytes

Contents

module Thumbs

  class NotFound
    F = ::File
    
    def initialize(app, image_not_found)
      @app = app
      file = F.expand_path(image_not_found)
      @content = F.read(file)
    end

    def call(env)
      status, headers, body = @app.call(env)
      if status == 200
        [status, headers, body]
      else
        env['thumbs.logger'] << "not_found"
        [404, {}, @content]
      end
    end
    
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thumbs-0.0.6 lib/thumbs/middleware/not_found.rb
thumbs-0.0.5 lib/thumbs/middleware/not_found.rb
thumbs-0.0.4 lib/thumbs/middleware/not_found.rb
thumbs-0.0.3 lib/thumbs/middleware/not_found.rb