Module: Rack
- Defined in:
- lib/rack/multiplexer.rb,
lib/rack/multiplexer/version.rb
Overview
Provides a simple router & dispatcher for Rack applications as a Rack application. The routing algorithm has only O(1) time complexity because all routes are compiled into one Regexp.
Example:
# config.ru
multiplexer = Rack::Multiplexer.new
multiplexer.get("/a", ->(env) { [200, {}, ["a"]] })
multiplexer.get("/b", ->(env) { [200, {}, ["b"]] })
multiplexer.put("/c", ->(env) { [200, {}, ["c"]] })
multiplexer.get("/d/:e", ->(env) { [200, {}, [env["rack.request.query_hash"]["e"]]] })
run multiplexer
Defined Under Namespace
Classes: Multiplexer