dpp66953
2018-07-06 07:27
浏览 1.7k
已采纳

在Golang中获取POST参数,并将标头作为application / json

I am new to golang and trying to create REST API with POST Method using httprouter (https://github.com/julienschmidt/httprouter). I am using simple raw request with header as Content-Type : application/json.

I have tried hard but not getting way to fetch raw query parameters.

req.FormValue("name") or req.Form.Get("name") is working fine but with header as Content-Type : application/x-www-form-urlencoded

Has anyone tried fetching raw query parameters(with header as Content-Type : application/json)?

图片转代码服务由CSDN问答提供 功能建议

我是golang的新手,正尝试使用Http方法使用POST方法创建REST API( https://github.com/julienschmidt/httprouter )。 我正在使用简单的原始请求,其标头为Content-Type:application /

我已经尽力了,但是没有办法获取原始查询参数。

req.FormValue(“ name”)或req.Form .Get(“ name”)工作正常,但标头为Content-Type:application / x-www-form-urlencoded

有人尝试获取原始查询参数(标头为Content) -Type:application / json)?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题