-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.go
50 lines (42 loc) · 893 Bytes
/
web.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
package main
import (
"github.com/gin-gonic/gin"
)
// Header is html header data
type Header struct {
GithubClientID string
StaticDomain string
RestfulDomain string
UserLang string
Debug bool
VersionName string
}
func html(fn func(p *Context) (int, string, interface{})) gin.HandlerFunc {
return func(c *gin.Context) {
ctx := &Context{c}
status, name, body := fn(ctx)
_lang := ctx.UserLang()
header := header()
header.UserLang = _lang
data := struct {
Lang string
Header Header
Body interface{}
}{
Lang: _lang,
Header: header,
Body: body,
}
c.HTML(status, name, data)
c.Abort()
}
}
func header() Header {
var header Header
header.GithubClientID = config.Gci
header.StaticDomain = config.Ssd
header.RestfulDomain = config.Rad
header.Debug = config.Debug
header.VersionName = VersionName
return header
}