Allow users to HTML template error messages - #271
Conversation
|
Hi @tlwr, Just wanted to say thanks for being a great community member! I look forward to reviewing this PR when you are ready! |
49ec777 to
950db67
Compare
|
Thank you for your kind words @ameowlia :D I've updated the description for this PR and all the tests which do not use the Am I good to raise a routing-release PR? I don't want to create unwanted noise 📢 unless it is warranted :) |
|
Hi @tlwr, This looks good to me. I'm going to let another team member review before I merge it in. Once we merge it then you can make the bump PR to routing-release that points at the merge commit. We'll let you do it though so you get credit 👍 |
so we can render HTML error messages in future Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
like the http pkg Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
and integration tests Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
which includes headers, status, and message Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
Signed-off-by: toby lorne <toby@toby.codes>
|
Rebased on latest main, merge conflict resolved (git didn't know what to do with this diff) |
|
@tlwr heads up - we have our hands full this week, so it may take us a little bit to get to this, but I know we aim to review it as soon as we can. In the meantime, would you mind opening an issue on routing-release to capture your intent here and surface it to the community? we are trying to make routing-release issues be the entry point for community discussions about changes to routing-release and underlying components. it'd be good to surface this there sooner than later. |
cloudfoundry/gorouter#271 Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
|
Hi @mcwumbly I totally understand, no worries at all :) I've raised a PR cloudfoundry/routing-release#179 against routing-release which should hopefully make it easier to review when you get a chance |
cloudfoundry/gorouter#271 Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
cloudfoundry/gorouter#271 Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
Checklist
Context
Currently, when gorouter encounters an error (eg route not found) a user receives a plaintext error response using
http.Error, which looks like this:This is usually not a big problem because we do not expect users to see gorouter error pages often, however they do occur often enough that users notice:
This has been discussed before in #171 but the work was not pursued
Explanation
This PR does not change the behaviour of gorouter unless using a newly created configuration parameter
html_error_template_file.Templates are written using go
html/templatesyntax.Using this parameter, Gorouter can be configured to generate HTML error messages that render nicely in a user's browser, and an operator can configure the templates to provide additional contextual information that would otherwise require a user to open up their developer tools.
For example:
I have also created a GOV.UK PaaS error page:
Screenshot of GOV.UK PaaS error page
The following HTML is the relevant bit:
How to review
Create a configuration file
/tmp/gorouter.ymlwith contents:Create a template
/tmp/example.htmlwith contents:Run gorouter:
go build && ./gorouter -c /tmp/example.yamlNavigate to http://localhost:8081 and observe there is a HTML page which includes
Future behaviour
Error pages in your browser render HTML instead of plain text.
Current behaviour
Error pages cannot be templated, and render as plain text.
Other PRs
If this change is welcome I will raise a routing release PR which allows a user to provide a template via the gorouter BOSH job.
Checklist
I have viewed signed and have submitted the Contributor License Agreement
I have made this pull request to the⚠️ I've done this to
developbranch (mainnotdevelopwhich I think is correct)I have run all the unit tests using
scripts/run-unit-tests-in-docker(Optional) I have run Routing Acceptance Tests and Routing Smoke Tests on bosh lite
(Optional) I have run CF Acceptance Tests on bosh lite