Skip to content

Add HTTP multi-method routes API - #1

Merged
ChiragAgg5k merged 2 commits into
mainfrom
feat-http-routes-api
Jun 10, 2026
Merged

Add HTTP multi-method routes API#1
ChiragAgg5k merged 2 commits into
mainfrom
feat-http-routes-api

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

What does this PR do?

Adds Http::routes() to the HTTP package so one route handler can be registered for multiple HTTP methods:

Http::routes([Http::REQUEST_METHOD_GET, Http::REQUEST_METHOD_POST], '/oauth/userinfo')
    ->action(...);

This supports endpoints such as OpenID Connect UserInfo, where the same endpoint must accept both GET and POST, without duplicating route actions or adding another alias-specific public API.

Implementation

  • Adds Http::routes(string|array $methods, string $url): Route.
  • Keeps Http::get(), post(), put(), patch(), and delete() as single-method wrappers around routes().
  • Stores route methods as one ordered array on Route; the first method remains available through deprecated Route::getMethod() for backwards compatibility.
  • Adds Route::getMethods() for route metadata.
  • Registers every method in the router under the same path template and Route instance.
  • Preserves path alias behavior so Http::routes([GET, POST], '/new')->alias('/old') matches both methods under both paths.
  • Pre-validates method support, method path conflicts, and alias path conflicts before writing to the route table, preventing partial registrations when an exception is thrown.

Test plan

  • bin/monorepo check http
  • bin/monorepo test http

Comment thread packages/http/src/Http/Router.php Outdated
@ChiragAgg5k
ChiragAgg5k merged commit 3d9c9f9 into main Jun 10, 2026
3 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat-http-routes-api branch June 10, 2026 11:18
loks0n added a commit that referenced this pull request Jun 10, 2026
loks0n added a commit that referenced this pull request Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants