/
init.go
55 lines (44 loc) · 1.19 KB
/
init.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
55
package init
import (
"encoding/json"
"net/http"
"strconv"
// HDX imports
"github.com/OpenHDX/web-api/modules"
"github.com/OpenHDX/web-api/shared"
"github.com/OpenHDX/web-api/token"
)
type Init struct {
AppCountry string `json:"appCountry"`
AppLanguage string `json:"appLanguage"`
ServerTime int64 `json:"serverTime"`
Verifier string `json:"verifier,omitempty"`
}
type Module struct{}
func (m *Module) Get(conn *shared.ConnInfo) {
init, _ := json.Marshal(Init{
conn.BusinessInfo.Country,
conn.BusinessInfo.Language,
conn.RequestTime,
token.New(conn.Fingerprint, conn.Domain, strconv.FormatInt(conn.RequestTime, 10), shared.VERIFIER_KEY)})
conn.Response.Body.Write(init)
}
func (m *Module) Post(conn *shared.ConnInfo) {
conn.Response.StatusCode = http.StatusMethodNotAllowed
return
}
func (m *Module) Put(conn *shared.ConnInfo) {
conn.Response.StatusCode = http.StatusMethodNotAllowed
return
}
func (m *Module) Patch(conn *shared.ConnInfo) {
conn.Response.StatusCode = http.StatusMethodNotAllowed
return
}
func (m *Module) Delete(conn *shared.ConnInfo) {
conn.Response.StatusCode = http.StatusMethodNotAllowed
return
}
func init() {
modules.Register("init", &Module{})
}