Add more Shengqu apis

Signed-off-by: Yuan Si <do4suki@gmail.com>
This commit is contained in:
2023-04-24 14:01:44 +08:00
parent d464a17178
commit e1e0e8c27d
3 changed files with 24 additions and 20 deletions
+6
View File
@@ -475,6 +475,12 @@ func GetProductListHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, resp)
}
func GuestStatusHandler(ctx *gin.Context) {
resp := `{"code":0,"msg":"ok","data":{"disablead":1,"loginswitch":1,"message":"ok","result":0}}`
ctx.Header("Content-Type", "text/html;charset=utf-8")
ctx.String(http.StatusOK, resp)
}
func ReportLog(ctx *gin.Context) {
// body, err := io.ReadAll(ctx.Request.Body)
// CheckErr(err)
+2
View File
@@ -31,6 +31,7 @@ func main() {
v1 := r.Group("v1")
{
v1.GET("/basic/getcode", handler.GetCodeHandler)
v1.POST("/basic/getcode", handler.GetCodeHandler)
v1.POST("/account/active", handler.ActiveHandler)
v1.POST("/basic/publickey", handler.PublicKeyHandler)
v1.POST("/basic/handshake", handler.HandshakeHandler)
@@ -40,6 +41,7 @@ func main() {
v1.POST("/basic/loginarea", handler.LoginAreaHandler)
v1.POST("/account/reportRole", handler.ReportRoleHandler)
v1.POST("/basic/getProductList", handler.GetProductListHandler)
v1.POST("/guest/status", handler.GuestStatusHandler)
}
r.GET("/agreement/all", handler.AgreementHandler)
r.GET("/integration/appReport/initialize", handler.ReportApp)
+16 -20
View File
@@ -9,29 +9,25 @@ import (
)
func ParseMultipartForm(ctx *gin.Context) {
if ctx.Request.Header.Get("OS") != "Android" {
// I don't know why mime.ParseMediaType() is failed
// mime.ParseMediaType(ctx.Request.Header.Get("Content-Type"))
boundary := strings.ReplaceAll(ctx.Request.Header.Get("Content-Type"), "multipart/form-data; boundary=", "")
// I don't know why mime.ParseMediaType() is failed
// mime.ParseMediaType(ctx.Request.Header.Get("Content-Type"))
boundary := strings.ReplaceAll(ctx.Request.Header.Get("Content-Type"), "multipart/form-data; boundary=", "")
var reqData []byte
mReader := multipart.NewReader(ctx.Request.Body, boundary)
for {
part, err := mReader.NextPart()
if err == io.EOF {
break
}
CheckErr(err)
data, err := io.ReadAll(part)
CheckErr(err)
reqData = data
var reqData []byte
mReader := multipart.NewReader(ctx.Request.Body, boundary)
for {
part, err := mReader.NextPart()
if err == io.EOF {
break
}
ctx.Set("request_data", string(reqData))
} else {
ctx.Set("request_data", ctx.PostForm("request_data"))
CheckErr(err)
data, err := io.ReadAll(part)
CheckErr(err)
reqData = data
}
ctx.Set("request_data", string(reqData))
ctx.Next()
}