In Go's http package, how do I get the query string on a POST request?

前端 未结 6 612
滥情空心
滥情空心 2021-01-30 03:59

I\'m using the httppackage from Go to deal with POST request. How can I access and parse the content of the query string from the Requestobject ? I can

6条回答
  •  没有蜡笔的小新
    2021-01-30 04:25

    There are two ways of getting query params:

    1. Using reqeust.URL.Query()
    2. Using request.Form

    In second case one has to be careful as body parameters will take precedence over query parameters. A full description about getting query params can be found here

    https://golangbyexample.com/net-http-package-get-query-params-golang

提交回复
热议问题