Sha256: 486856e9c69b3af00ace817565d1910b6011bb0a0cd1af93e14f6320801104e1

Contents?: true

Size: 994 Bytes

Versions: 13

Compression:

Stored size: 994 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, description, endpoint)
    endpoints.push(
        {
            :request_method => request_method,
            :request_path => Rack::App::Utils.normalize_path(request_path),
            :description => description,
            :endpoint => endpoint
        }
    )

    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

13 entries across 13 versions & 1 rubygems

Version Path
rack-app-3.6.0 lib/rack/app/router/base.rb
rack-app-3.5.2 lib/rack/app/router/base.rb
rack-app-3.5.1 lib/rack/app/router/base.rb
rack-app-3.5.0 lib/rack/app/router/base.rb
rack-app-3.4.0 lib/rack/app/router/base.rb
rack-app-3.3.0 lib/rack/app/router/base.rb
rack-app-3.2.1 lib/rack/app/router/base.rb
rack-app-3.2.0 lib/rack/app/router/base.rb
rack-app-3.1.0 lib/rack/app/router/base.rb
rack-app-3.0.0 lib/rack/app/router/base.rb
rack-app-3.0.0.delta lib/rack/app/router/base.rb
rack-app-3.0.0.gamma lib/rack/app/router/base.rb
rack-app-3.0.0.beta lib/rack/app/router/base.rb