Module: Roda::RodaPlugins::PathMatchers

Defined in:
lib/roda/plugins/path_matchers.rb

Overview

The path_matchers plugin adds hash matchers that operate on the request’s path.

It adds a :prefix matcher for matching on the path’s prefix, yielding the rest of the matched segment:

r.on prefix: 'foo' do |suffix|
  # Matches '/foo-bar', yielding '-bar'
  # Does not match bar-foo
end

It adds a :suffix matcher for matching on the path’s suffix, yielding the part of the segment before the suffix:

r.on suffix: 'bar' do |prefix|
  # Matches '/foo-bar', yielding 'foo-'
  # Does not match bar-foo
end

It adds an :extension matcher for matching on the given file extension, yielding the part of the segment before the extension:

r.on extension: 'bar' do |reset|
  # Matches '/foo.bar', yielding 'foo'
  # Does not match bar.foo
end

Defined Under Namespace

Modules: RequestMethods