beeGo框架如何一次性获取get请求的所有参数

相关环境:go1.14 + beego1.12

我现在的路由是这样的:

http://127.0.0.1:8088/test?name=jim&age=9

在控制器获取url参数是c.GetString(“name”),c.GetString(“age”)。
但是我觉得这样太麻烦了,能不能一次性全部拿到参数呢?这样方便记日志什么的。
我试过:c.Ctx.Input.Context.Request.Form,但是这个只在post情况下才有用。

最佳答案

c.Ctx.Input.Params() map[string]string 这个方法可以获取

1年前 评论
bluememory (楼主) 1年前
deatil (作者) 1年前
deatil (作者) 1年前
bluememory (楼主) 1年前
deatil (作者) 1年前
bluememory (楼主) 1年前
deatil (作者) 1年前
bluememory (楼主) 1年前
deatil (作者) 1年前
讨论数量: 11

c.Ctx.Input.Params() map[string]string 这个方法可以获取

1年前 评论
bluememory (楼主) 1年前
deatil (作者) 1年前
deatil (作者) 1年前
bluememory (楼主) 1年前
deatil (作者) 1年前
bluememory (楼主) 1年前
deatil (作者) 1年前
bluememory (楼主) 1年前
deatil (作者) 1年前

试下data, err := c.Input()呢,我拿出来了

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!