接收带有 # 的 Golang GET 请求中的 URL 参数。

huangapple go评论65阅读模式
英文:

Receiving Golang GET request with # in the URL parameter

问题

我正在尝试为Shopify创建一个履约应用程序,他们每小时向我的应用程序的端点发送一次调用,其中包含他们需要我提供跟踪号码的订单名称。

不幸的是,订单名称中包含“#”(例如#1001.1)。当我收到这些调用时,查询参数在“#”处被截断,查询字符串的其余部分不再显示。当我从调用中删除“#”(在测试时),整个查询字符串都会传递过来。

带有“#”的请求:

请求:

GET http://localhost:4200/v1/fetch_tracking_numbers.json?order_names[]=#1001.1&order_names[]=#1002.1&order_names[]=#1003.2

服务器端记录的请求:

GET http://localhost:4200/v1/fetch_tracking_numbers.json?order_names[]=

没有“#”的请求:

请求:

GET http://localhost:4200/v1/fetch_tracking_numbers.json?order_names[]=1001.1&order_names[]=1002.1&order_names[]=1003.2

服务器端记录的请求:

GET http://localhost:4200/v1/fetch_tracking_numbers.json?order_names[]=1001.1&order_names[]=1002.1&order_names[]=1003.2

我正在使用基于fasthttp的atreugo。

谢谢!

英文:

I'm trying to create a fulfillment app for shopify, and they send a call once an hour to an endpoint on my app, with the order names they need me to provide tracking numbers for.

Unfortunately the order names have "#" in them (ex. #1001.1). When I receive these calls the query arguments get cut off at the # and the rest of the query string no longer shows. When I remove the # from the call (while testing), the whole query string comes through.

With #'s

Request

GET http://localhost:4200/v1/fetch_tracking_numbers.json?order_names[]=#1001.1&order_names[]=#1002.1&order_names[]=#1003.2

Logged Request on server side

GET http://localhost:4200/v1/fetch_tracking_numbers.json?order_names[]=

Without #'s

Request

GET http://localhost:4200/v1/fetch_tracking_numbers.json?order_names[]=1001.1&order_names[]=1002.1&order_names[]=1003.2

Logged Request on server side

GET http://localhost:4200/v1/fetch_tracking_numbers.json?order_names[]=1001.1&order_names[]=1002.1&order_names[]=1003.2

I'm using atreugo built on top of fasthttp.

Thanks!

答案1

得分: 1

只想在这里回应一下最新情况。
我是个白痴。
Shopify对他们的请求URI进行了编码。

他们的文档误导了我,再加上我的愚蠢。感谢所有试图帮助我的人!

英文:

Just want to respond here with an update.
I'm an idiot.
Shopify encodes their request URI's.

Their docs mislead me, along with my stupidity. Thanks to everyone who tried to help!

huangapple
  • 本文由 发表于 2021年11月13日 04:44:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/69948850.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定