module Roda::RodaPlugins::MapMatcher

  1. lib/roda/plugins/map_matcher.rb

The map_matcher plugin allows you to provide a string-keyed hash during route matching, and match any of the keys in the hash as the next segment in the request path, yielding the corresponding value in the hash:

class App < Roda
  plugin :map_matcher

  map = { "foo" => "bar", "baz" => "quux" }.freeze

  route do
    r.get map: map do |v|
      v
      # GET /foo => bar
      # GET /baz => quux
    end
  end
end