Sha256: 0a52d068b1de5f543df94d4d33cd1a9e29844000a3bb0bcd7b36076e1ce21a8e

Contents?: true

Size: 995 Bytes

Versions: 2

Compression:

Stored size: 995 Bytes

Contents

class Rack::App::Router::Base

  def call(env)

    request_method= env[Rack::REQUEST_METHOD]
    path_info= env[Rack::PATH_INFO]

    context = fetch_context(request_method, path_info)
    return unless context.is_a?(Hash) and not context[:endpoint].nil?

    format_env(context, env)
    context[:endpoint].call(env)

  end

  def format_env(context, env)
  end

  def endpoints
    @endpoints ||= []
  end

  def register_endpoint!(request_method, request_path, endpoint, properties={})
    endpoints.push(
        {
            :request_method => request_method,
            :request_path => Rack::App::Utils.normalize_path(request_path),
            :endpoint => endpoint,
            :properties => properties
        }
    )

    compile_registered_endpoints!
    return endpoint
  end

  protected

  def fetch_context(request_method, request_path)
    raise('IMPLEMENTATION MISSING ERROR')
  end

  def compile_registered_endpoints!
    raise('IMPLEMENTATION MISSING ERROR')
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-app-5.0.0.rc1 lib/rack/app/router/base.rb
rack-app-4.0.1 lib/rack/app/router/base.rb