Sha256: b1fee6b82c3f41f6247fbb8bb322da9d34a2428dc9c4ebf566f0112722d377bd
Contents?: true
Size: 634 Bytes
Versions: 1
Compression:
Stored size: 634 Bytes
Contents
require "railroad/switch/version" module Railroad module Switch class << self attr_reader :route attr_accessor :fallback_to def app Application.new end def register(path:, app:) @route ||= {} @route[path] = app end end class Application def call(env) app = Railroad::Switch.route&.fetch(env['PATH_INFO'], nil) if app app.call(env) elsif Railroad::Switch.fallback_to Railroad::Switch.fallback_to.call(env) else [404, { "X-Cascade" => "pass" }, []] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
railroad-switch-0.1.0 | lib/railroad/switch.rb |