douyou2732 2013-11-04 09:50
浏览 52

GoREST端点路径

I'm writting a web service with Go and I'd like to have url like :

http://example.com/WEB/service.wfs?param1=2&param2=test.....

I'm using GoREST and my Endpoint url is :

method:"GET" path:"/WEB/service.wfs?{param:string}" output:"string"

My problem is that it never return the "param" but it does if I use the endpoint :

method:"GET" path:"/WEB/service.wfs/{param:string}" output:"string"

Is there a way to handle the "?" ?

  • 写回答

2条回答 默认 最新

  • duandai6373 2013-12-03 16:39
    关注

    I have had a look at the GoREST package you are using and can not see any way of doing this.

    I have always used gorillatoolkit pat package.

    gorillatoolkit

    There is an example of what you want to do about half way down.

    category := req.URL.Query().Get(":category")
    

    This way you can get the query parameters on the request URL by the key.

    Hope this helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改