Sha256: ca0fbc3e552c9fcbf070fbaca4f82a7127f94988d54b42153d9ebd60d0541f49

Contents?: true

Size: 1.8 KB

Versions: 42

Compression:

Stored size: 1.8 KB

Contents

module Rack::App::SingletonMethods::HttpMethods

  protected

  def get(path = '/', &block)
    add_route(::Rack::App::Constants::HTTP::METHOD::GET, path, Rack::App::Block.new(&block))
  end

  def post(path = '/', &block)
    add_route(::Rack::App::Constants::HTTP::METHOD::POST, path, Rack::App::Block.new(&block))
  end

  def put(path = '/', &block)
    add_route(::Rack::App::Constants::HTTP::METHOD::PUT, path, Rack::App::Block.new(&block))
  end

  def delete(path = '/', &block)
    add_route(::Rack::App::Constants::HTTP::METHOD::DELETE, path, Rack::App::Block.new(&block))
  end

  def head(path = '/', &block)
    add_route(::Rack::App::Constants::HTTP::METHOD::HEAD, path, Rack::App::Block.new(&block))
  end

  def options(path = '/', &block)
    add_route(::Rack::App::Constants::HTTP::METHOD::OPTIONS, path, Rack::App::Block.new(&block))
  end

  def patch(path = '/', &block)
    add_route(::Rack::App::Constants::HTTP::METHOD::PATCH, path, Rack::App::Block.new(&block))
  end

  def link(path = '/', &block)
    add_route(::Rack::App::Constants::HTTP::METHOD::LINK, path, Rack::App::Block.new(&block))
  end

  def unlink(path = '/', &block)
    add_route(::Rack::App::Constants::HTTP::METHOD::UNLINK, path, Rack::App::Block.new(&block))
  end

  def trace(path = '/', &block)
    add_route(::Rack::App::Constants::HTTP::METHOD::TRACE, path, Rack::App::Block.new(&block))
  end

  def alias_endpoint(new_request_path, original_request_path)
    new_request_path = Rack::App::Utils.normalize_path(new_request_path)
    original_request_path = Rack::App::Utils.normalize_path(original_request_path)

    router.endpoints.select { |ep| ep.request_path == original_request_path }.each do |endpoint|
      new_endpoint = endpoint.fork(:request_path => new_request_path)
      router.register_endpoint!(new_endpoint)
    end
  end

end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
rack-app-7.3.2 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.3.1 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.3.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.2.2 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.2.1 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.2.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.1.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.0.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.8.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.7.1 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.7.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.6.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.5.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.4.1 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.4.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.3.3 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.3.2 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.3.1 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.3.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-6.2.0 lib/rack/app/singleton_methods/http_methods.rb