Sha256: 7ef89d1d9982088007e10f101a2a41748b0342f1c65d1136290899bda42862ae

Contents?: true

Size: 584 Bytes

Versions: 1

Compression:

Stored size: 584 Bytes

Contents

module Peictt
  module Http
    class Checker
      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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
peictt-0.1.1 lib/peictt/http/checker.rb