class Peictt::Http::Checker

Public Class Methods

check_url(env, routes) click to toggle source
# File lib/peictt/http/checker.rb, line 4
def self.check_url(env, routes)
  routes.each do |route|
    params = {}
    match = route.regexp.match(env["PATH_INFO"])
    if match && ((env["REQUEST_METHOD"] == route.verb) ||
      (route.verb.include? env["REQUEST_METHOD"]))
      unless route.placeholders.empty?
        params = route.placeholders.zip(match.captures).to_h
      end
      return [route, params]
    end
  end

  -> (_env) { [404, {}, ["Route not found"]] }
end