Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpcaddyfile: Refactor to allow named matchers in route blocks #3632

Merged
merged 1 commit into from
Aug 5, 2020

Conversation

francislavoie
Copy link
Member

@francislavoie francislavoie commented Aug 4, 2020

While updating caddyserver/website#71 I figured I'd take a look at what it would take to fix route to allow named matchers within it, turned out to be pretty simple.

There's was plenty of duplicate code in the logic of parseRoute compared to parseSegmentAsSubroute, but we didn't want the logic from buildSubroute for route because it does things we don't need.

It was pretty simple to extract out everything except the call to buildSubroute into an internal function so that route and handle can share almost entirely the same code paths.

(I recommend reviewing with "hide whitespace changes" turned on, makes the diff clearer)

@francislavoie francislavoie added this to the v2.2.0 milestone Aug 4, 2020
@francislavoie francislavoie requested a review from mholt August 4, 2020 11:14
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is an elegant change. Thanks for the test case. I don't see any problems with this so far so let's put it in the 2.2 beta and see how it flies!

@mholt mholt removed the under review 🧐 Review is pending before merging label Aug 5, 2020
@mholt mholt merged commit 584eba9 into caddyserver:master Aug 5, 2020
@francislavoie francislavoie deleted the matchers-in-route branch August 5, 2020 19:46
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