Skip to content

feat(routing): Route::get/post, Route::behind and HandlerReference::of — the verb once, the door once - #21

Merged
rodrigoteamx merged 1 commit into
mainfrom
rodrigoteamx/DX
Sep 14, 2026
Merged

rodrigoteamx merged 1 commit into
mainfrom
rodrigoteamx/DX

Conversation

@rodrigoteamx

Copy link
Copy Markdown
Contributor

What

  • Route::get() / Route::post() build the very Route the constructor builds, the verb said once as the method name and the handler named [Controller::class, 'method'].
  • HandlerReference::of() derives the reference from that pair and refuses any other shape by naming what it received (eight malformed cases tested, non-UTF-8 included).
  • Route::behind($middleware, ...$routes) prepends one door to a group; Route::withMiddleware() is the wither behind it.
  • Only what has a consumer in the family ships (36 GET / 19 POST / 0 other verbs across getmilpa-*/src): put/patch/delete and a bare Controller::class arrive with their first caller (greenhouse decisions/0213).

Why

A plugin author paid five new Route(path:, methods:, name:, middleware:, handler: new HandlerReference(...)) blocks for information that fits one line each, and repeated the gate on every route. The constructor stays the canon; nothing is invented (greenhouse decisions/0212).

Measured

Consumer in the same arc: getmilpa/agent-workspace routes() rewritten with this (48 lines → 13). On fresh cattle routes:list --json is byte-identical to the published tree; only the declaration order moves (the public assets route last), which the Router's segment matching makes harmless and a test now declares. Full record: greenhouse decisions/0386, evidence/0704.

Gates

55 tests / 151 assertions · line coverage 100.00 % (92/92), floor 100 · PHPStan 6 clean · docblocks OK · php-cs-fixer 0/28 · attribution OK.

Release

Additive API → feat: → 0.5.0 under bump-minor-pre-major. getmilpa/agent-workspace requires >=0.5 <1.0 and waits for this tag.

…roup

Route::get() and Route::post() build the very Route the constructor builds, with the
verb said once — as the method name — and the handler named the way a controller is
named, [Controller::class, 'method'], through HandlerReference::of(), which refuses
any other shape by naming what it received. Route::behind($middleware, ...$routes)
prepends one door to a group of routes; Route::withMiddleware() is the wither behind
it. Only the verbs and the handler shape with a consumer in the family exist here:
put/patch/delete and a bare Controller::class arrive with their first caller.

Measured in the greenhouse: agent-workspace's five routes rewritten with this
produce a byte-identical routes:list on fresh cattle; only the declaration order
moves, and a test declares it (greenhouse decisions/0386, evidence/0704).
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.

1 participant