-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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: Add optional status code argument to handle_errors
directive
#5965
httpcaddyfile: Add optional status code argument to handle_errors
directive
#5965
Conversation
You can add tests for the Caddyfile translation to JSON. See this directory for examples: You can also test the behavior by adding tests to this file: |
f35dad2
to
3597097
Compare
@mohammed90 For the attached Caddyfile, does the attahced json file looks right? This works but I am not sure if this is the expected result. |
Don't make it one giant test. Break it into multiple ones that target a specific transformation behavior. You can have the giant test as an additional one to ensure the smaller parts still function properly even when merged. It also helps you with validating your understanding of the implementation as you manually do the process which you've automated. At a glance, it seems correct, but break it apart to make the review easier and the validation more concrete and accurate. |
Might need a test that covers having |
Sounds good. I will work on adding the tests and see about the multiple site blocks. However, can someone explain why are all those test jobs failing? The logs within the jobs themselves are not super helpful :'( |
Oh I think we need to update the test files for the old handle_errors am I right? |
This test is failing:
And you'll need to run |
5da75b6
to
a949a21
Compare
@mohammed90 I broke down the test into 4 smaller pieces: I also made sure the test that was failing in the pipelines is now passing. Please let me know if there is anything else I should do for you to be able to review my code. Thank you! |
Great! Tests and linter are passing. I think the last thing to handle is multiple site blocks, making sure they stay mutually exclusive. The existing tests will probably need to be adjusted as well to make sure they're wrapped with a subroute with a |
handle_errors
directive
@francislavoie I think I get what you mean. I will try to put something together for that shortly. Thank you for the feedback. |
@francislavoie By multiple site blocks do you mean something like the attached Caddyfile? If so, that is working properly with the current code. Let me know if I am not understanding your request correctly. |
Not quite, I mean 2 sites with the different hosts but the same port. So like:
This will use the same |
@francislavoie, Okay I now understand what you mean. But how would you think this should look like in the context of handling errors. Should the routes have 2 matchers? A host matcher and an expression matcher? Is that possible? |
It should work the same as the non-error routes. Each site produces a subroute with a host matcher, then all the error handlers for that site go within that matcher. Nested subroutes. |
@francislavoie. I think it's all good now. I added a test caddyfile to account for the multiple site blocks case. I also adjusted other tests to include the host matcher in them. |
Hi @francislavoie, I just wanted to bring your attention to this PR again. Your feedback on the latest changes would be appreciated if you still see issues with the changes suggested here. Thank you! |
3adc63a
to
38df5ae
Compare
Yep, holidays and things 😂 thanks for the reminder, doing a round of review now. |
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 great! I made a quick commit to remove leftovers from the first commit that isn't needed anymore. This also needs a bit more validation logic to ensure bad inputs are rejected. Almost ready!
7f4b9c8
to
3e94051
Compare
@francislavoie thank you for your feedback. The requested changes should now be implemented. |
I don't see any changes since I last reviewed 🤔 did you forget to push? |
9013bb2
to
37e8eff
Compare
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.
That's better, thank you!
37e8eff
to
b46f7e8
Compare
Resolves #5928
I am pretty sure there is a lot that can be improved here since this is my first PR. I particularly don't like the way I add the expression matcher to the subroutes created inside the
parseHandleErrors
and I am pretty there is a better way of doing it.Thank you in advance for reviewing my code!