Skip to content

Tech: extract the proxy rule parser into ProxyRule - #35

Merged
edersoares merged 1 commit into
mainfrom
proxy-rule
Sep 30, 2026
Merged

edersoares merged 1 commit into
mainfrom
proxy-rule

Conversation

@edersoares

Copy link
Copy Markdown
Owner

Summary

  • Adds src/ProxyRule.php, a readonly value object with fromString() that parses one entry of FRONTIER_PROXY_RULES (exact, cache, methods(...), middleware(...), replace(...), rewrite(...)) plus url(), routeUri() and replaces() to resolve the parts that depend on the host.
  • Frontier::proxy() shrinks from ~90 to ~30 lines and only registers the route. The dead $methods = [] assignment goes away.
  • Adds tests/Unit/ProxyRuleTest.php with 13 tests covering each segment, defaults, segment order and malformed segments. Until now the parser was only exercised through HTTP tests.

Pure refactor, no behavior change. The 42 existing tests pass without edits.

Test plan

  • composer test (55 passed)
  • vendor/bin/pint --test

🤖 Generated with Claude Code

Frontier::proxy() parsed the rule string, built the route config and
registered the route in a single method. The parsing now lives in
ProxyRule, a value object with its own unit tests, and the method only
registers the route.

The existing proxy tests cover the registered routes and keep passing
unchanged, so the behavior is preserved.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@edersoares
edersoares merged commit e2f1db0 into main Sep 30, 2026
1 check passed
@edersoares
edersoares deleted the proxy-rule branch September 30, 2026 17:18
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