selfcare init
This commit is contained in:
148
proxy_go/Nrestful/rest_response.go
Normal file
148
proxy_go/Nrestful/rest_response.go
Normal file
@@ -0,0 +1,148 @@
|
||||
package Nrestful
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
//"fmt"
|
||||
//"log"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
//"time"
|
||||
|
||||
l4g "proxy/logger"//"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func sendAuthCodeRsp(w http.ResponseWriter, statusCode int, rsp *RestRsp) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
if statusCode != http.StatusOK {
|
||||
rsp.AuthCodeRsp.Code = strconv.Itoa(5001)
|
||||
} else {
|
||||
//rsp.AuthCodeRsp.Code = 2001
|
||||
}
|
||||
w.WriteHeader(statusCode)
|
||||
l4g.RestLog.Warnf("Send AuthCodeRsp: %v", rsp.AuthCodeRsp)
|
||||
|
||||
// w.Write at last
|
||||
json.NewEncoder(w).Encode(rsp.AuthCodeRsp)
|
||||
//
|
||||
}
|
||||
|
||||
func sendQueryUserDataRsp(w http.ResponseWriter, statusCode int, rsp *RestRsp) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
if statusCode != http.StatusOK {
|
||||
rsp.QueryUserDataRsp.Code = strconv.Itoa(5001)
|
||||
} else {
|
||||
//rsp.QueryUserDataRsp.Code = 2001
|
||||
}
|
||||
w.WriteHeader(statusCode)
|
||||
l4g.RestLog.Warnf("Send QueryUserDataRsp: %v", rsp.QueryUserDataRsp)
|
||||
|
||||
// w.Write at last
|
||||
json.NewEncoder(w).Encode(rsp.QueryUserDataRsp)
|
||||
//
|
||||
}
|
||||
|
||||
func sendBundleSubsRsp(w http.ResponseWriter, statusCode int, rsp *RestRsp) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
if statusCode != http.StatusOK {
|
||||
rsp.BundleSubsRsp.Code = strconv.Itoa(5001)
|
||||
} else {
|
||||
//rsp.BundleSubsRsp.Code = 2001
|
||||
}
|
||||
w.WriteHeader(statusCode)
|
||||
l4g.RestLog.Warnf("Send QueryUserDataRsp: %v", rsp.BundleSubsRsp)
|
||||
|
||||
// w.Write at last
|
||||
json.NewEncoder(w).Encode(rsp.BundleSubsRsp)
|
||||
//
|
||||
}
|
||||
|
||||
func sendRechargeRsp(w http.ResponseWriter, statusCode int, rsp *RestRsp) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
if statusCode != http.StatusOK {
|
||||
rsp.RechargeRsp.Code = strconv.Itoa(5001)
|
||||
} else {
|
||||
//rsp.RechargeRsp.Code = 2001
|
||||
}
|
||||
w.WriteHeader(statusCode)
|
||||
l4g.RestLog.Warnf("Send RechargeRsp: %v", rsp.RechargeRsp)
|
||||
|
||||
// w.Write at last
|
||||
json.NewEncoder(w).Encode(rsp.RechargeRsp)
|
||||
//
|
||||
}
|
||||
|
||||
func sendTransferRsp(w http.ResponseWriter, statusCode int, rsp *RestRsp) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
if statusCode != http.StatusOK {
|
||||
rsp.TransferRsp.Code = strconv.Itoa(5001)
|
||||
} else {
|
||||
//rsp.TransferRsp.Code = 2001
|
||||
}
|
||||
w.WriteHeader(statusCode)
|
||||
l4g.RestLog.Warnf("Send TransferRsp: %v", rsp.TransferRsp)
|
||||
|
||||
// w.Write at last
|
||||
json.NewEncoder(w).Encode(rsp.TransferRsp)
|
||||
//
|
||||
}
|
||||
|
||||
func sendQueryBalanceRsp(w http.ResponseWriter, statusCode int, rsp *RestRsp) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
if statusCode != http.StatusOK {
|
||||
rsp.QueryBalanceRsp.Code = strconv.Itoa(5001)
|
||||
} else {
|
||||
//rsp.QueryBalanceRsp.Code = 2001
|
||||
}
|
||||
w.WriteHeader(statusCode)
|
||||
l4g.RestLog.Warnf("Send QueryBalanceRsp: %v", rsp.QueryBalanceRsp)
|
||||
|
||||
// w.Write at last
|
||||
json.NewEncoder(w).Encode(rsp.QueryBalanceRsp)
|
||||
//
|
||||
}
|
||||
|
||||
func sendCreateAccountRsp(w http.ResponseWriter, statusCode int, rsp *RestRsp) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
if statusCode != http.StatusOK {
|
||||
rsp.CreateAccountRsp.Code = strconv.Itoa(5001)
|
||||
} else {
|
||||
//rsp.CreateAccountRsp.Code = 2001
|
||||
}
|
||||
w.WriteHeader(statusCode)
|
||||
l4g.RestLog.Warnf("Send CreateAccountRsp: %v", rsp.CreateAccountRsp)
|
||||
|
||||
// w.Write at last
|
||||
json.NewEncoder(w).Encode(rsp.CreateAccountRsp)
|
||||
//
|
||||
}
|
||||
|
||||
func sendUpdateSubsRsp(w http.ResponseWriter, statusCode int, rsp *RestRsp) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
if statusCode != http.StatusOK {
|
||||
rsp.UpdateSubsRsp.Code = strconv.Itoa(5001)
|
||||
} else {
|
||||
//rsp.UpdateSubsRsp.Code = 2001
|
||||
}
|
||||
w.WriteHeader(statusCode)
|
||||
l4g.RestLog.Warnf("Send UpdateSubsRsp: %v", rsp.UpdateSubsRsp)
|
||||
|
||||
// w.Write at last
|
||||
json.NewEncoder(w).Encode(rsp.UpdateSubsRsp)
|
||||
//
|
||||
}
|
||||
|
||||
func sendDeleteSubsRsp(w http.ResponseWriter, statusCode int, rsp *RestRsp) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
if statusCode != http.StatusOK {
|
||||
rsp.DeleteSubsRsp.Code = strconv.Itoa(5001)
|
||||
} else {
|
||||
//rsp.DeleteSubsRsp.Code = 2001
|
||||
}
|
||||
w.WriteHeader(statusCode)
|
||||
l4g.RestLog.Warnf("Send DeleteSubsRsp: %v", rsp.DeleteSubsRsp)
|
||||
|
||||
// w.Write at last
|
||||
json.NewEncoder(w).Encode(rsp.DeleteSubsRsp)
|
||||
//
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user