Sha256: f7dba7113ead912abeceb642e3b8f2ae0036a45ad7f74580021be5d5d1265bcb

Contents?: true

Size: 1.32 KB

Versions: 29

Compression:

Stored size: 1.32 KB

Contents

module Rack::App::SingletonMethods::RouteHandling
  def router
    @router ||= Rack::App::Router.new
  end

  protected

  def root(endpoint_path)
    alias_endpoint('/', endpoint_path)
  end

  def route_registration_properties
    @route_registration_properties ||= {}
  end

  def description(*description_texts)
    route_registration_properties[:description] = description_texts.join("\n")
  end

  alias desc description

  def add_route(request_method, request_path, callable)
    router.register_endpoint!(
      Rack::App::Endpoint.new(:ancestors => [self],
                              :callable => callable,
                              :payload => payload,
                              :error_handler => error,
                              :request_method => request_method,
                              :route => route_registration_properties.dup,
                              :endpoint_specific_middlewares => next_endpoint_middlewares.dup,
                              :request_path => ::Rack::App::Utils.join(namespace, request_path))
    )

    next_endpoint_middlewares.clear
    route_registration_properties.clear
    nil
  end

  def namespace(*namespace_paths)
    @namespaces ||= []
    @namespaces.push(namespace_paths)
    yield if block_given?
    @namespaces.pop
    ::Rack::App::Utils.join(@namespaces.flatten)
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
rack-app-11.0.2 lib/rack/app/singleton_methods/route_handling.rb
rack-app-11.0.1 lib/rack/app/singleton_methods/route_handling.rb
rack-app-11.0.0 lib/rack/app/singleton_methods/route_handling.rb
rack-app-10.0.0 lib/rack/app/singleton_methods/route_handling.rb
rack-app-9.0.0 lib/rack/app/singleton_methods/route_handling.rb
rack-app-8.1.0 lib/rack/app/singleton_methods/route_handling.rb
rack-app-8.0.1 lib/rack/app/singleton_methods/route_handling.rb
rack-app-8.0.0 lib/rack/app/singleton_methods/route_handling.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/rack-app-7.7.0/lib/rack/app/singleton_methods/route_handling.rb
rack-app-7.7.0 lib/rack/app/singleton_methods/route_handling.rb
rack-app-7.6.5 lib/rack/app/singleton_methods/route_handling.rb
rack-app-7.6.4 lib/rack/app/singleton_methods/route_handling.rb
rack-app-7.6.3 lib/rack/app/singleton_methods/route_handling.rb
rack-app-7.6.2 lib/rack/app/singleton_methods/route_handling.rb
rack-app-7.6.1 lib/rack/app/singleton_methods/route_handling.rb
rack-app-7.6.0 lib/rack/app/singleton_methods/route_handling.rb
rack-app-7.5.2 lib/rack/app/singleton_methods/route_handling.rb
rack-app-7.5.1 lib/rack/app/singleton_methods/route_handling.rb
rack-app-7.5.0 lib/rack/app/singleton_methods/route_handling.rb
rack-app-7.4.0 lib/rack/app/singleton_methods/route_handling.rb