mirrored from https://git.sr.ht/~ancarda/tls-redirector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
52 lines (38 loc) · 986 Bytes
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"bytes"
"text/template"
_ "embed"
)
var (
//go:embed templates/acme404Message.html
acme404Message string
//go:embed templates/acme404TI.html
acme404TI string
//go:embed templates/emptyHostHeader.html
emptyHostHeader string
//go:embed templates/genericMessage.html
genericMessage string
//go:embed templates/hostHeaderIsIPTechInfo.html
hostHeaderIsIPTechInfo string
//go:embed templates/pageTemplate.html
pageTemplate string
)
var pageT *template.Template
func init() { pageT = template.Must(template.New("").Parse(pageTemplate)) }
// errorPage produces a nice looking HTML error page.
func errorPage(title, message, ti, ver string) []byte {
footer := "<footer>Powered by tls-redirector/" + ver + "</footer>"
dat := struct {
Title string
Message string
TI string
Footer string
}{title, message, ti, footer}
var buf bytes.Buffer
err := pageT.Execute(&buf, dat)
if err != nil {
panic(err)
}
return buf.Bytes()
}