Sha256: aa2bfefbbac6942d4ba3158a55a9d1eba5245aa56fb5887d7eae0ae0e964db0e

Contents?: true

Size: 877 Bytes

Versions: 3

Compression:

Stored size: 877 Bytes

Contents

module Rack::App::SingletonMethods::HttpMethods

  def get(path = '/', &block)
    add_route('GET', path, &block)
  end

  def post(path = '/', &block)
    add_route('POST', path, &block)
  end

  def put(path = '/', &block)
    add_route('PUT', path, &block)
  end

  def head(path = '/', &block)
    add_route('HEAD', path, &block)
  end

  def delete(path = '/', &block)
    add_route('DELETE', path, &block)
  end

  def options(path = '/', &block)
    add_route('OPTIONS', path, &block)
  end

  def patch(path = '/', &block)
    add_route('PATCH', path, &block)
  end

  def alias_endpoint(new_request_path, original_request_path)
    router.endpoints.select { |ep| ep[:request_path] == original_request_path }.each do |endpoint|
      router.register_endpoint!(endpoint[:request_method], new_request_path, endpoint[:description], endpoint[:endpoint])
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-app-2.3.1 lib/rack/app/singleton_methods/http_methods.rb
rack-app-2.3.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-2.2.0 lib/rack/app/singleton_methods/http_methods.rb