-
Notifications
You must be signed in to change notification settings - Fork 0
/
title_storage.go
98 lines (90 loc) · 2.32 KB
/
title_storage.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package main
import (
"crypto/sha256"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"time"
)
type TitleStorageResponse struct {
Checksum string `json:"checksum"`
DownloadURL string `json:"download_url"`
LastUpdated string `json:"last_updated"`
Size int `json:"size"`
}
func TitleStorage(w http.ResponseWriter, r *http.Request) {
rec := httptest.NewRecorder()
TitleStorageGateways(rec, nil)
data, _ := ioutil.ReadAll(rec.Result().Body)
resp := buildPlatformSuccess(TitleStorageResponse{
Checksum: fmt.Sprintf("%x", sha256.Sum256(data)),
DownloadURL: "https://api.bethesda.net/titlestorage/actualstorage/gateways",
LastUpdated: time.Now().String(),
Size: 100,
})
DefaultJSONEncoder(w, resp)
}
type GatewayResp struct {
Global Global `json:"global"`
Regions []Region `json:"regions"`
}
type Global struct {
Services []Service `json:"services"`
}
type Region struct {
ID int `json:"id"`
PingURL string `json:"ping_url"`
Services []Service `json:"services"`
}
type Service struct {
Name string `json:"name"`
PublicKey string `json:"pubkey"`
URL string `json:"url"`
}
func TitleStorageGateways(w http.ResponseWriter, _ *http.Request) {
regionIDs := []int{11, 6, 7, 8, 2, 3, 5}
regions := []Region{}
for _, regionID := range regionIDs {
region := Region{
ID: regionID,
PingURL: fmt.Sprintf("https://api.bethesda.net/regions/%d/ping", regionID),
Services: []Service{
Service{
Name: "bps-gatewayreg",
PublicKey: "nokey",
URL: fmt.Sprintf("https://api.behtesda.net/region/%d/gatewayreg", regionID),
},
},
}
regions = append(regions, region)
}
resp := GatewayResp{
Global: Global{
Services: []Service{
Service{
Name: "bps-loginqueue",
PublicKey: "loginqueue_key",
URL: "https://api.bethesda.net/loginqueue",
},
Service{
Name: "bps-gateway",
PublicKey: "loginqueue_key",
URL: "https://api.bethesda.net/gateway",
},
Service{
Name: "bps-bigateway",
PublicKey: "loginqueue_key",
URL: "https://api.bethesda.net/bigateway",
},
Service{
Name: "bps-pushy",
PublicKey: "loginqueue_key",
URL: "https://api.bethesda.net/pushy",
},
},
},
Regions: regions,
}
DefaultJSONEncoder(w, resp)
}