rack-middleware
Purpose.
All things Rack in Merb: Rack middleware, Rack profiler, etc.
Middleware.
Merb comes with simple Middleware for serving static files and profiling. Middleware classes behave like any other Rack applications but do some work before or after delegating to main Rack application.
For instance here is how you use profiling middleware:
# use PathPrefix Middleware if :path_prefix is set in Merb::Config
if prefix = ::Merb::Config[:path_prefix]
use Merb::Rack::PathPrefix, prefix
end
# comment this out if you are running merb behind a load balancer
# that serves static files
use Merb::Rack::Static, Merb.dir_for(:public)
# profile Merb Rack application call
run Merb::Rack::Profiler.new(Merb::Rack::Application.new, 10, 10)
it wraps Merb Rack application that handles requests into block that execution is profiled. Put this code into config/rack.rb in your application and check out log/profiler_output.html page for results.
Problems.
Merb 0.9.3 tries to find a controller when serving static files.
error: “Controller ‘Stylesheets’ not found.” solution: configure rack to load static files from the public directory by adding “use Merb::Rack::Static, Merb.dir_for(:public)” to config/rack.rb in your application.
See this announcement