feat(smalltrip,problem): use handler browser as default handler
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"slices"
|
"slices"
|
||||||
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Problem interface {
|
type Problem interface {
|
||||||
@@ -52,8 +53,25 @@ func New(opts ...Option) RegisteredProblem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
DefaultTypeURI = "about:blank"
|
DefaultTypeURI = "about:blank"
|
||||||
DefaultHandler = HandlerAll
|
DefaultTemplate = template.Must(template.New("x-smalltrip-problem-template").Parse(`
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{{ .Status }} - {{ .Title }}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>{{.Status}} - {{ .Title }}</h1>
|
||||||
|
<p><code>{{ .Type }}</code></p>
|
||||||
|
<p>{{ .Detail }}</p>
|
||||||
|
{{if .Instance}}
|
||||||
|
<p>Instance: {{ .Instance }}</p>
|
||||||
|
{{end}}
|
||||||
|
<code>{{printf "%#v" .}}<code>
|
||||||
|
</body>
|
||||||
|
<html>
|
||||||
|
`))
|
||||||
|
DefaultHandler = HandlerMiddleware(HandlerBrowser(DefaultTemplate))
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p RegisteredProblem) Type() string {
|
func (p RegisteredProblem) Type() string {
|
||||||
|
|||||||
Reference in New Issue
Block a user