-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
caddyhttp: Support single-line not matcher shortcut #3228
Conversation
Nice, I wonder what a good testing approach is for this? Perhaps a usecase in here caddy/caddyconfig/httpcaddyfile/httptype_test.go Lines 9 to 33 in 84c729e
|
I don't think |
Understood, I think that test name is bit misleading because it is actually testing the parsing of a matcher. ps: I think you are underating yourself :) |
I'll rename |
Added a couple test cases, but I don't think there's a huge amount of value here because it didn't return a warning or error before with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks @francislavoie ! Congrats on your first Go-centric PR. 😃
@@ -559,7 +559,7 @@ func (m *MatchNot) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { | |||
for d.Next() { | |||
var mp matcherPair | |||
matcherMap := make(map[string]RequestMatcher) | |||
for d.NextBlock(0) { | |||
for d.NextArg() || d.NextBlock(0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is clever, but I do admit I think it's kinda weird. We can go with it for now and fix it later if people complain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about it do you find weird?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just an unusual condition for a parsing loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk, reads perfectly fine to me. 🤷♂
"While there's still an arg or a block ahead, loop to read for additional matchers"
Simple addition to make it possible to have
not
negate a matcher on the same line instead of requiring it to be contained in a block.E.g. before:
after: