-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
能否支持SetHeader多次使用呢,现在使用起来看起来只能使用一次 #203
Comments
现状SetHeader目前是只能调用一次,多次调用后面的会覆盖前面。如果要传递多个header,只要传递slice or map or struct类等的数据就行。更多SetHeader用法例子 func arrayExample() {
// 2.使用slice变量
fmt.Printf("======2. SetHeader======use slice=====\n")
err := gout.GET(":8080/test.header").
Debug(true).
SetHeader(gout.A{"h1", "v1",
"h2", 2,
"h3", float32(3.14),
"h4", 4.56,
"h5", time.Now().Unix(),
"h6", time.Now().UnixNano(),
"h7", time.Now().Format("2006-01-02")}).
Do()
if err != nil {
fmt.Printf("%s\n", err)
return
}
} 后续你提的我会考虑下,不过目前优先级不会太高。支持多次调用要的效果,在目前单次调用SetHeader里面都可以实现。 以前不支持多次调用SetHeader的考虑有。
|
好的,有时候多个业务需要一个公用的头部,每个业务可能有不同的头部,先设置公用的头部之后,再分别各自的头部,不过这都不是问题,可以设计一下就好了。 |
hi, @chanyipiaomiao 实现你的需求,现在有两套方案,我们可以讨论下。
SetHeader(结构体1, 结构体2)
SetHeader(结构体1).SetHeader( 结构体2) 目前考虑目前倾向于第一种方案,更符合go的风格,也是整个go标准库惯用的方式。第二种方案中用多次SetHeader实现的却是append的语义,实现这样的行为感觉怪怪的。 |
可以的。 |
ok,那就第一种。 |
Merged
功能已经提交到master分支,可以体验下。 |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
能否支持SetHeader多次使用呢,现在使用起来看起来只能使用一次
The text was updated successfully, but these errors were encountered: