-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocs.go
49 lines (43 loc) · 865 Bytes
/
docs.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
package shiftapi
import (
"html/template"
"io"
)
const redocTemplate string = `<!DOCTYPE html>
<html>
<head>
<title>{{.Title}}</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="{{.FaviconURL}}">
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<redoc spec-url="{{.SpecURL}}"></redoc>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
</body>
</html>
`
type redocData struct {
Title string
FaviconURL string
RedocURL string
SpecURL string
// EnableGoogleFonts bool
}
func genRedocHTML(data redocData, out io.Writer) error {
t, err := template.New("redocHTML").Parse(redocTemplate)
if err != nil {
return err
}
err = t.Execute(out, data)
if err != nil {
return err
}
return nil
}