-
Notifications
You must be signed in to change notification settings - Fork 1
/
docs.go
54 lines (45 loc) · 1.22 KB
/
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
50
51
52
53
54
package handlers
import (
"fmt"
"net/http"
"github.com/containeroo/heartbeats/internal/docs"
"github.com/containeroo/heartbeats/internal/utils"
"github.com/gorilla/mux"
)
// Docs is the handler for the docs page
func Docs(w http.ResponseWriter, req *http.Request) {
LogRequest(req)
templs := []string{
"web/templates/base.html",
"web/templates/navbar.html",
"web/templates/docs.html",
"web/templates/docs/api.html",
"web/templates/footer.html",
}
ParseTemplates("base", templs, &docs.Documentation, w)
}
// Chapter is the handler for the documentation chapters
func Chapter(w http.ResponseWriter, req *http.Request) {
LogRequest(req)
vars := mux.Vars(req)
chapter := vars["chapter"]
var templs []string
if !utils.IsInListOfStrings(docs.Chapters, chapter) {
templs = []string{
"web/templates/base.html",
"web/templates/navbar.html",
"web/templates/docs.html",
"web/templates/docs/404.html",
"web/templates/footer.html",
}
} else {
templs = []string{
"web/templates/base.html",
"web/templates/navbar.html",
"web/templates/docs.html",
fmt.Sprintf("web/templates/docs/%s.html", chapter),
"web/templates/footer.html",
}
}
ParseTemplates("base", templs, &docs.Documentation, w)
}