-
-
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
Caddyfile handle_errors
optional status code argument
#5928
Comments
I like this idea. |
Hi, |
Sure @pkkht, PRs welcome. |
Ah,, unable to contribute due to change in circumstances. Sorry about that! |
Hello, I would like to contribute. Can I pick this issue up? |
Sure 👍 |
Thank you! I am on it then! |
In the description of the issue, does multiple status codes just mean two status codes? From the looks of it we are looking at ranges here right? Also, how do you suggest going about enforcing that a handle_error directive without arguments should come last? |
Not only 2. It can be any number of arguments or something like
You can either keep it aside in the parsing process then append it at the end after parsing all other handlers, or manage the sorting logic in your implementation of the |
Sorry for the multiple follow ups and maybe the "trivial" questions, but I guess I am a little bit confused on how I should be approaching this. Is the idea here to build a new Also, we need to make sure that if someone has the arguments, they are not allowed to have the current |
See caddy/modules/caddyhttp/rewrite/caddyfile.go Line 155 in 18f3429
Basically just need to update Bonus points (not required, but nice to have) for handling So
In addition, the code in Run |
Thank you for the detailed response! |
@francislavoie, I think I am almost there, I got individual Thanks in advance for your help! |
That's handled in the pile thing. It'll need to loop through those and insert them as routes in the final config (instead of only grabbing one). |
One more thing to add here, looks like Again, sorry if my questions are very trivial, I am still learning the way we want to do things here. |
Hmm, are you referring to the one argument being the
Not at all; you're contributing in a place that very few other people have even read the code for. |
@mholt I was referring to the arguments on the first line right after the |
Oh ok, cool -- thanks for working on this! Sounds like you're figuring it out (and it's a bit complicated, so kudos) |
The
handle_errors
directive is useful for implementing custom error pages and such.Currently, its ergonomics are not great, because matching errors by status code needs to be done via a
handle
with anexpression
matcher (see examples in the docs).I suggest that we add an optional status code argument (or variadic multiple status codes) to
handle_errors
as a shortcut for wrapping the routes in a status code matcher. For example:This would effectively be the same as:
Using
handle_errors
this way multiple times should simply append more routes. Ahandle_errors
with no arguments (no matcher) should always be inserted last to ensure it acts as a fallback.The text was updated successfully, but these errors were encountered: