feat(smalltrip,problem): use handler browser as default handler

This commit is contained in:
Guz
2025-07-30 19:14:43 -03:00
parent e2e26c89e0
commit 94db7c51ea

View File

@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"slices" "slices"
"text/template"
) )
type Problem interface { type Problem interface {
@@ -53,7 +54,24 @@ 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 {