-
Notifications
You must be signed in to change notification settings - Fork 5
/
meta.go
70 lines (59 loc) · 1.56 KB
/
meta.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"encoding/json"
"net/http"
)
func ListSearchAllTypes(w http.ResponseWriter, r *http.Request) {
WriteCacheHeader(&w)
if err := json.NewEncoder(w).Encode(searchAllowedIndices); err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
}
func GetGameVersion(w http.ResponseWriter, r *http.Request) {
WriteCacheHeader(&w)
if err := json.NewEncoder(w).Encode(CurrentVersion); err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
}
func ListItemTypeIds(w http.ResponseWriter, r *http.Request) {
txn := Db.Txn(false)
defer txn.Abort()
it, err := txn.Get("item-type-ids", "id")
if err != nil || it == nil {
w.WriteHeader(http.StatusNotFound)
return
}
var typeIds []string
for obj := it.Next(); obj != nil; obj = it.Next() {
effectElement := obj.(*ItemTypeId)
typeIds = append(typeIds, effectElement.EnName)
}
WriteCacheHeader(&w)
err = json.NewEncoder(w).Encode(typeIds)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
}
func ListEffectConditionElements(w http.ResponseWriter, r *http.Request) {
txn := Db.Txn(false)
defer txn.Abort()
it, err := txn.Get("effect-condition-elements", "id")
if err != nil || it == nil {
w.WriteHeader(http.StatusNotFound)
return
}
var effects []string
for obj := it.Next(); obj != nil; obj = it.Next() {
effectElement := obj.(*EffectConditionDbEntry)
effects = append(effects, effectElement.Name)
}
WriteCacheHeader(&w)
err = json.NewEncoder(w).Encode(effects)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
}