Commit fd5cfd1ba436141886b080b4cf856f1e85f1cd52
1 parent
27d2008c
Exists in
master
and in
1 other branch
feat✨:调试接口
Showing
3 changed files
with
31 additions
and
0 deletions
Show diff stats
controllers/demo.go
| ... | ... | @@ -4,6 +4,7 @@ import ( |
| 4 | 4 | "apigame/models" |
| 5 | 5 | "apigame/service/code-msg" |
| 6 | 6 | "apigame/util/util-lx/lxalilog" |
| 7 | + "encoding/json" | |
| 7 | 8 | "fmt" |
| 8 | 9 | ) |
| 9 | 10 | |
| ... | ... | @@ -44,3 +45,20 @@ func (c *DemoController) Demo() { |
| 44 | 45 | |
| 45 | 46 | c.RetRspCodeData(code_msg.RECODE_OK, rsp) |
| 46 | 47 | } |
| 48 | + | |
| 49 | +// Dump Dump | |
| 50 | +func (c *DemoController) Dump() { | |
| 51 | + req := new(models.ReqDump) | |
| 52 | + | |
| 53 | + err := json.Unmarshal(c.Ctx.Input.RequestBody, &req) | |
| 54 | + if err != nil { | |
| 55 | + c.RetCode(code_msg.RECODE_PARAMERROR) | |
| 56 | + return | |
| 57 | + } | |
| 58 | + | |
| 59 | + rsp := models.RspDump{} | |
| 60 | + | |
| 61 | + rsp.Text = "hello" | |
| 62 | + | |
| 63 | + c.RetRspCodeData(code_msg.RECODE_OK, rsp) | |
| 64 | +} | ... | ... |
models/demo.go
| ... | ... | @@ -9,3 +9,15 @@ type ReqDemo struct { |
| 9 | 9 | // RspDemo 返回 |
| 10 | 10 | type RspDemo struct { |
| 11 | 11 | } |
| 12 | + | |
| 13 | +// ReqDump 请求 | |
| 14 | +type ReqDump struct { | |
| 15 | + GameID string `form:"gameid" json:"gameid"` | |
| 16 | + Mode string `form:"mode" json:"mode"` | |
| 17 | + Args []string `form:"args" json:"args"` | |
| 18 | +} | |
| 19 | + | |
| 20 | +// RspDump 返回 | |
| 21 | +type RspDump struct { | |
| 22 | + Text string `form:"text" json:"text"` | |
| 23 | +} | ... | ... |
routers/router.go
| ... | ... | @@ -33,5 +33,6 @@ func init() { |
| 33 | 33 | beego.Router(prefix+"/roomrank/addscore", &controllers.RoomRankController{}, "post:AddScore") |
| 34 | 34 | |
| 35 | 35 | beego.Router(prefix+"/demo", &controllers.DemoController{}, "post:Demo") |
| 36 | + beego.Router(prefix+"/puchidump", &controllers.DemoController{}, "post:Dump") | |
| 36 | 37 | beego.ErrorController(&controllers.ErrorController{}) |
| 37 | 38 | } | ... | ... |