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

Gorouter can be configured with HTML error pages #179

Closed
wants to merge 2 commits into from

Conversation

tlwr
Copy link
Contributor

@tlwr tlwr commented Aug 18, 2020

What

Read gorouter#271 for detailed information

Allows an operator to use a Go template to customise the error pages, for example:

<html>
  <body>
    Code: {{ .Status }} {{ .StatusText }}<br>
    Message: {{ .Message }}<br>
    Cause: {{ .Header.Get "X-Cf-RouterError" }}
  </body>
</html>

Why

As an operator, I would like to customise the error pages, so that my end-users get a more helpful error page.

As an operator, I would like to return HTML in the error pages, because plaintext error pages scare my users.

How to test

Deploy the following ops file to a CF deployment

- type: replace
  path: /releases/name=routing
  value:
    name: "routing"
    version: 0.0.1597688047
    url: https://s3-eu-west-1.amazonaws.com/gds-paas-build-releases/routing-0.0.1597688047.tgz
    sha1: 55c752a94605245e34bf2eacc0d89969c16e5724

- type: replace
  path: /instance_groups/name=router/jobs/name=gorouter/properties/router/html_error_template?
  value: |
    <html>
      <body>
        Code: {{ .Status }} {{ .StatusText }}
        <br>
        Message: {{ .Message }}
        <br>
        Cause: {{ .Header.Get "X-Cf-RouterError" }}
      </body>
    </html>

Expected result

A HTML error page with contents:

<html>
  <body>
    Code: 404 Not Found
    <br>
    Message: Requested route (&#39;404.route&#39;) does not exist.
    <br>
    Cause: unknown_route
  </body>
</html>

 

Current result

A plaintext error page with contents:

404 Not Found: Requested route ('404.route') does not exist.

Other PRs

cloudfoundry/gorouter#271

Checklist

  • I have viewed signed and have submitted the Contributor License Agreement
  • I have made this pull request to the develop branch
  • 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 cf-deployment
  • (Optional) I have run CF Acceptance Tests on bosh lite cf-deployment

Toby Lorne added 2 commits Aug 17, 2020
cloudfoundry/gorouter#271

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
@jrussett
Copy link
Contributor

@jrussett jrussett commented Aug 20, 2020

👋 @tlwr

We manually merged your commits on top of develop, see:
abd514a

This will be included in the next release of Routing release.

Thank you so much for contributing 😄

@jrussett jrussett closed this Aug 20, 2020
@tlwr
Copy link
Contributor Author

@tlwr tlwr commented Aug 20, 2020

Thank you all so much! :D

jrussett pushed a commit that referenced this issue Aug 20, 2020
fixes:
```
spec/gorouter_templates_spec.rb:856:23: C: Redundant curly braces around a hash parameter.
      template.render({ 'router' => { 'html_error_template' => html } })
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

See related PR: #179

[#174320914](https://www.pivotaltracker.com/story/show/174320914)

Signed-off-by: Josh Russett <jrussett@vmware.com>
@tlwr tlwr deleted the html-templates branch Aug 21, 2020
@jrussett
Copy link
Contributor

@jrussett jrussett commented Sep 1, 2020

Hey @tlwr,

This feature was released in Routing Release 0.207.0.

Thanks again!
@jrussett

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.

None yet

2 participants