bson을 json으로 통일(일단은)
This commit is contained in:
@ -281,8 +281,8 @@ func (gp *groupParty) JoinParty(w http.ResponseWriter, r *http.Request) {
|
||||
Character bson.M `bson:"character"`
|
||||
First bool `bson:"first"`
|
||||
}
|
||||
if err := gocommon.ReadBsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("JoinParty failed. ReadBsonDocumentFromBody returns err :", err)
|
||||
if err := gocommon.ReadJsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("JoinParty failed. ReadJsonDocumentFromBody returns err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
@ -329,7 +329,8 @@ func (gp *groupParty) JoinParty(w http.ResponseWriter, r *http.Request) {
|
||||
Body: gd.loadFull(),
|
||||
Tag: []string{"GroupDocFull"},
|
||||
})
|
||||
writeBsonDoc(w, map[string]string{
|
||||
enc := json.NewEncoder(w)
|
||||
enc.Encode(map[string]string{
|
||||
"gid": gid.Hex(),
|
||||
"tid": gd.tid(mid),
|
||||
})
|
||||
@ -374,8 +375,8 @@ func (gp *groupParty) InviteToParty(w http.ResponseWriter, r *http.Request) {
|
||||
Invitee bson.M `bson:"invitee"`
|
||||
}
|
||||
|
||||
if err := gocommon.ReadBsonDocumentFromBody(r.Body, &doc); err != nil {
|
||||
logger.Println("InviteToParty failed. ReadBsonDocumentFromBody returns err :", err)
|
||||
if err := gocommon.ReadJsonDocumentFromBody(r.Body, &doc); err != nil {
|
||||
logger.Println("InviteToParty failed. ReadJsonDocumentFromBody returns err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
@ -456,8 +457,8 @@ func (gp *groupParty) AcceptPartyInvitation(w http.ResponseWriter, r *http.Reque
|
||||
Tid string `bson:"tid"`
|
||||
Character bson.M `bson:"character"`
|
||||
}
|
||||
if err := gocommon.ReadBsonDocumentFromBody(r.Body, &doc); err != nil {
|
||||
logger.Println("AcceptPartyInvitation failed. ReadBsonDocumentFromBody returns err :", err)
|
||||
if err := gocommon.ReadJsonDocumentFromBody(r.Body, &doc); err != nil {
|
||||
logger.Println("AcceptPartyInvitation failed. ReadJsonDocumentFromBody returns err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
@ -546,8 +547,8 @@ func (gp *groupParty) DenyPartyInvitation(w http.ResponseWriter, r *http.Request
|
||||
Mid primitive.ObjectID `bson:"mid"`
|
||||
}
|
||||
|
||||
if err := gocommon.ReadBsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("DenyPartyInvitation failed. ReadBsonDocumentFromBody returns err :", err)
|
||||
if err := gocommon.ReadJsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("DenyPartyInvitation failed. ReadJsonDocumentFromBody returns err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
@ -568,8 +569,8 @@ func (gp *groupParty) QueryPartyMemberState(w http.ResponseWriter, r *http.Reque
|
||||
Mid primitive.ObjectID `bson:"mid"`
|
||||
}
|
||||
|
||||
if err := gocommon.ReadBsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("DenyPartyInvitation failed. ReadBsonDocumentFromBody returns err :", err)
|
||||
if err := gocommon.ReadJsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("DenyPartyInvitation failed. ReadJsonDocumentFromBody returns err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
@ -597,8 +598,8 @@ func (gp *groupParty) LeaveParty(w http.ResponseWriter, r *http.Request) {
|
||||
Mid primitive.ObjectID `bson:"mid"`
|
||||
Tid string `bson:"tid"`
|
||||
}
|
||||
if err := gocommon.ReadBsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("LeaveParty failed. ReadBsonDocumentFromBody returns err :", err)
|
||||
if err := gocommon.ReadJsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("LeaveParty failed. ReadJsonDocumentFromBody returns err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
@ -711,8 +712,8 @@ func (gp *groupParty) UpdatePartyDocument(w http.ResponseWriter, r *http.Request
|
||||
Doc bson.M `bson:"doc"`
|
||||
}
|
||||
|
||||
if err := gocommon.ReadBsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("UpdatePartyDocument failed. ReadBsonDocumentFromBody returns err :", err)
|
||||
if err := gocommon.ReadJsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("UpdatePartyDocument failed. ReadJsonDocumentFromBody returns err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
@ -732,8 +733,8 @@ func (gp *groupParty) QueryPartyMembers(w http.ResponseWriter, r *http.Request)
|
||||
Gid primitive.ObjectID `bson:"gid"`
|
||||
}
|
||||
|
||||
if err := gocommon.ReadBsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("QueryPartyMembers failed. ReadBsonDocumentFromBody returns err :", err)
|
||||
if err := gocommon.ReadJsonDocumentFromBody(r.Body, &data); err != nil {
|
||||
logger.Println("QueryPartyMembers failed. ReadJsonDocumentFromBody returns err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
@ -751,7 +752,8 @@ func (gp *groupParty) QueryPartyMembers(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
if err := writeBsonDoc(w, members); err != nil {
|
||||
enc := json.NewEncoder(w)
|
||||
if err := enc.Encode(members); err != nil {
|
||||
logger.Error("QueryPartyMembers failed. writeBsonDoc return err :", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user