Skip to content
Permalink
Browse files

change error_pages to be enabled by default for text/html requests

  • Loading branch information...
tj committed Jan 2, 2018
1 parent d147813 commit f47c5c7f88442ba25397f7ce7d31117f736cae13
Showing with 17 additions and 9 deletions.
  1. +2 −2 config/errorpages.go
  2. +12 −3 docs/04-configuration.md
  3. +2 −3 http/errorpages/errorpages.go
  4. +1 −1 internal/cli/deploy/deploy.go
@@ -2,8 +2,8 @@ package config

// ErrorPages configuration.
type ErrorPages struct {
// Enable default error pages.
Enable bool `json:"enable"`
// Disable default error pages.
Disable bool `json:"disable"`

// Dir containing error pages.
Dir string `json:"dir"`
@@ -248,16 +248,15 @@ Date: Mon, 31 Jul 2017 20:49:35 GMT

## Error Pages

By default Up will serve a minimalistic error page for you if the client accepts `text/html`, and it is explicitly enabled.
By default Up will serve a minimalistic error page for requests accepting `text/html`.

You may customize the default template's `color` and optionally provide a `support_email` to allow customers to contact your support team.
The default template's `color` and optionally provide a `support_email` to allow customers to contact your support team.

```json
{
"name": "site",
"type": "static",
"error_pages": {
"enable": true,
"variables": {
"support_email": "support@apex.sh",
"color": "#228ae6"
@@ -294,6 +293,16 @@ Variables specified via `variables`, as well as `.StatusText` and `.StatusCode`
</html>
```

To disable the default template use:

```json
{
"error_pages": {
"disable": true
}
}
```

## Script Injection

Scripts, styles, and other tags may be injected to HTML pages before the closing `</head>` tag or closing `</body>` tag.
@@ -89,9 +89,8 @@ func New(c *up.Config, next http.Handler) (http.Handler, error) {
return nil, errors.Wrap(err, "loading error pages")
}

// skip unless errorpage files are present
// or explicitly enabled in up.json
if len(pages) == 1 && !c.ErrorPages.Enable {
// we always have one "default" page, but it can be disabled
if len(pages) == 1 && c.ErrorPages.Disable {
return next, nil
}

@@ -88,7 +88,7 @@ retry:
"has_cors": c.CORS != nil,
"has_logs": !c.Logs.Disable,
"has_profile": c.Profile != "",
"has_error_pages": c.ErrorPages.Enable,
"has_error_pages": !c.ErrorPages.Disable,
"app_name_hash": util.Md5(c.Name),
})

0 comments on commit f47c5c7

Please sign in to comment.
You can’t perform that action at this time.