Class: Madness::Static

Inherits:
Object
  • Object
show all
Defined in:
lib/madness/static.rb

Overview

The Madness::Static middleware delegates requests to Rack::TryStatic middleware unless the request URI ends with .md

Instance Method Summary collapse

Constructor Details

#initialize(app, options) ⇒ Static

Returns a new instance of Static.



6
7
8
9
# File 'lib/madness/static.rb', line 6

def initialize(app, options)
  @app = app
  @static = ::Rack::TryStatic.new(app, options)
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/madness/static.rb', line 11

def call(env)
  if env['PATH_INFO'].end_with? ".md"
    @app.call env
  else
    @static.call env
  end
end