module Xenon::Routing::PathDirectives

Public Instance Methods

path(pattern) { |*captures| ... } click to toggle source
# File lib/xenon/routing/path_directives.rb, line 27
def path(pattern)
  path_prefix(pattern) do |*captures|
    path_end do
      yield *captures
    end
  end
end
path_end() { || ... } click to toggle source
# File lib/xenon/routing/path_directives.rb, line 21
def path_end
  path_prefix(/\Z/) do
    yield
  end
end
path_prefix(pattern) { |*captures| ... } click to toggle source
# File lib/xenon/routing/path_directives.rb, line 8
def path_prefix(pattern)
  extract_request do |request|
    match = request.unmatched_path.match(pattern)
    if match && match.pre_match == ''
      map_request unmatched_path: match.post_match do
        yield *match.captures
      end
    else
      reject nil # path rejections are nil to allow more specific rejections to be seen
    end
  end
end