-
Notifications
You must be signed in to change notification settings - Fork 0
/
handlers.go
58 lines (44 loc) · 1.32 KB
/
handlers.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
package server
import (
"net/http"
"github.com/go-chi/chi"
)
type dtRelationship struct {
ServerID string
}
func (s *Server) relationshipHandler(w http.ResponseWriter, r *http.Request) {
s.rdr.renderXML(w, r, tplRelationship, &dtRelationship{chi.URLParam(r, "id")})
}
type dtSession struct {
Token string
}
func (s *Server) sessionHandler(w http.ResponseWriter, r *http.Request) {
if serverKey := getServerHeader(r); serverKey != "" {
s.rdr.renderXML(w, r, tplSession, nil)
return
}
userKey, err := r.Cookie("magma")
if err != nil {
http.Error(w, err.Error(), http.StatusUnprocessableEntity)
return
}
s.rdr.renderXML(w, r, tplSessionNew, &dtSession{userKey.Value})
}
type dtHero struct {
HeroID string
}
func (s *Server) entitlementsHandler(w http.ResponseWriter, r *http.Request) {
s.rdr.renderXML(w, r, tplSessionNew, &dtHero{chi.URLParam(r, "heroID")})
}
func (s *Server) offersHandler(w http.ResponseWriter, r *http.Request) {
s.rdr.renderXML(w, r, tplProducts, nil)
}
func (s *Server) walletsHandler(w http.ResponseWriter, r *http.Request) {
s.rdr.renderXML(w, r, tplWallets, nil)
}
func (s *Server) refundAbilitiesHandler(w http.ResponseWriter, r *http.Request) {
s.rdr.renderXML(w, r, tplWallets, nil)
}
func (s *Server) store(w http.ResponseWriter, r *http.Request) {
s.rdr.renderXML(w, r, tplStore, nil)
}