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-11.0.2 lib/rack/app/singleton_methods/http_methods.rb
rack-app-11.0.1 lib/rack/app/singleton_methods/http_methods.rb
rack-app-11.0.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-10.0.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-9.0.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-8.1.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-8.0.1 lib/rack/app/singleton_methods/http_methods.rb
rack-app-8.0.0 lib/rack/app/singleton_methods/http_methods.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/rack-app-7.7.0/lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.7.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.6.5 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.6.4 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.6.3 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.6.2 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.6.1 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.6.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.5.2 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.5.1 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.5.0 lib/rack/app/singleton_methods/http_methods.rb
rack-app-7.4.0 lib/rack/app/singleton_methods/http_methods.rb