-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcontentserver.go
More file actions
33 lines (28 loc) · 837 Bytes
/
contentserver.go
File metadata and controls
33 lines (28 loc) · 837 Bytes
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
package main
import (
"html/template"
"net/http"
)
// HTMLServer is a http.Handler for serving HTML content in the site theme. It
// is primarily designed for use with simple HTML content, generally converted
// from Markdown documents.
type HTMLServer struct {
GroupName string
Title string
Content template.HTML
}
// ServeHTTP implements the http.Handler interface, serving the Content HTML
// in the site theme.
func (h *HTMLServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
templateData, err := Asset("content.html")
if err != nil {
rw.Write([]byte("Error processing request, please try again later."))
return
}
t, err := template.New("homepage").Parse(string(templateData))
if err != nil {
rw.Write([]byte("Error processing request, please try again later."))
return
}
t.Execute(rw, h)
}