Sha256: 5e9f9ce3f19276920a4d1a008c0fc5542a7a0525ea9e1e42f65913a61c8c7ccb

Contents?: true

Size: 476 Bytes

Versions: 5

Compression:

Stored size: 476 Bytes

Contents

# frozen_string_literal: true

module Hanami
  class Router
    class GlobbedPath
      def initialize(http_method, path, to)
        @http_method = http_method
        @path = path
        @to = to
      end

      def endpoint_and_params(env)
        return [] unless @http_method == env[::Rack::REQUEST_METHOD]

        if (match = @path.match(env[::Rack::PATH_INFO]))
          [@to, match.named_captures]
        else
          []
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hanami-router-2.2.0 lib/hanami/router/globbed_path.rb
hanami-router-2.2.0.rc1 lib/hanami/router/globbed_path.rb
hanami-router-2.2.0.beta2 lib/hanami/router/globbed_path.rb
hanami-router-2.2.0.beta1 lib/hanami/router/globbed_path.rb
hanami-router-2.1.0 lib/hanami/router/globbed_path.rb