Sha256: 126341dd820a690c1e42cd76dba59422e9fcb3a3c3d52c8a35b965c1317f9d7c

Contents?: true

Size: 494 Bytes

Versions: 1

Compression:

Stored size: 494 Bytes

Contents

require 'rack'

module WhatsUpDoc
  class Middleware
    DEFAULTS = {path: '/up'}

    def initialize(app, options = {})
      @app = app
      @options = DEFAULTS.merge(options)
    end

    def call(env)
      @env = env

      if up_path?
        [200, {}, []]
      else
        app.call(env)
      end
    end

  private
    attr_reader :app, :env, :options

    def request
      Rack::Request.new(env)
    end

    def up_path?
      options[:path] == request.fullpath
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whats_up_doc-0.0.1 lib/whats_up_doc/middleware.rb