Closed userma000913 closed 1 year ago
这个和服务发现好像没什么关系吧同学,或者你能否给出更详细的代码或需求呢? 使用 POST 方法传入 JSON 类型的请求参数可以参考
如果是使用了服务发现不知道如何发送 POST 请求,可以参考一下 easy-demo
refer to https://github.com/li-jin-gou/nacos-demo/tree/main/example and I have observed that it does get a bit complicated to write, and we will add some complex ways of requesting it.
万分感谢,我大概懂了怎么发送请求,但是这是采用Do方法发送过去的,因为他自带一个post方法,应该也可以用它带的函数去做吧
这个和服务发现好像没什么关系吧同学,或者你能否给出更详细的代码或需求呢? 使用 POST 方法传入 JSON 类型的请求参数可以参考
- https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/route/
- https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/binding-and-validate/#%E6%94%AF%E6%8C%81%E7%9A%84-tag
如果是使用了服务发现不知道如何发送 POST 请求,可以参考一下 easy-demo
不不不,是服务发现的时候,调用其他服务的post接口时,传入的参数如何是json类型。 比如:在服务端在nacos里注册了一个服务,他有一个post接口,客户端在调用这个服务的post接口时,如何使用client带的post函数 status, body, err := client.Post(context.Background(), nil, "http://hertz.test.demo/ping", req, config.WithSD(true))
其实的确和服务发现没关系,更多的是client的如何使用,post 方法发送参数的话需要设置args,但是 args 不是body参数而是 form 参数,所以我的示例 使用了 Do,可以先按照提供的示例用。
没有开电脑用手机中文回复了🙏
---原始邮件--- 发件人: @.> 发送时间: 2022年12月17日(周六) 晚上6:32 收件人: @.>; 抄送: @.**@.>; 主题: Re: [hertz-contrib/registry] 能不能出一个post请求的方式哇 请求参数是json类型,孩子弄了半天也传不过去参数 (Issue #30)
这个和服务发现好像没什么关系吧同学,或者你能否给出更详细的代码或需求呢? 使用 POST 方法传入 JSON 类型的请求参数可以参考
https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/route/
如果是使用了服务发现不知道如何发送 POST 请求,可以参考一下 easy-demo
不不不,是服务发现的时候,调用其他服务的post接口时,传入的参数如何是json类型。 比如:在服务端在nacos里注册了一个服务,他有一个post接口,客户端在调用这个服务的post接口时,如何使用client带的post函数 status, body, err := client.Post(context.Background(), nil, "http://hertz.test.demo/ping", req, config.WithSD(true))
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
其实的确和服务发现没关系,更多的是client的如何使用,post 方法发送参数的话需要设置args,但是 args 不是body参数而是 form 参数,所以我的示例 使用了 Do,可以先按照提供的示例用。 没有开电脑用手机中文回复了🙏 … ---原始邮件--- 发件人: @.> 发送时间: 2022年12月17日(周六) 晚上6:32 收件人: @.>; 抄送: @.**@.>; 主题: Re: [hertz-contrib/registry] 能不能出一个post请求的方式哇 请求参数是json类型,孩子弄了半天也传不过去参数 (Issue #30) 这个和服务发现好像没什么关系吧同学,或者你能否给出更详细的代码或需求呢? 使用 POST 方法传入 JSON 类型的请求参数可以参考 https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/route/ https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/binding-and-validate/#%E6%94%AF%E6%8C%81%E7%9A%84-tag 如果是使用了服务发现不知道如何发送 POST 请求,可以参考一下 easy-demo 不不不,是服务发现的时候,调用其他服务的post接口时,传入的参数如何是json类型。 比如:在服务端在nacos里注册了一个服务,他有一个post接口,客户端在调用这个服务的post接口时,如何使用client带的post函数 status, body, err := client.Post(context.Background(), nil, "http://hertz.test.demo/ping", req, config.WithSD(true)) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
嗯呢 确实 我看源码里面请求头的type不是json,我清楚咋回事啦,谢谢大佬!!
@li-jin-gou 说实话Post
这个api
有点反直觉,具体体现在单元测试都没人用,要不要转到hertz
下。
这里说的是添加 post 请求的 example,不是 feature。
---原始邮件--- 发件人: @.> 发送时间: 2022年12月17日(周六) 晚上7:12 收件人: @.>; 抄送: @.**@.>; 主题: Re: [hertz-contrib/registry] 能不能出一个post请求的方式哇 请求参数是json类型,孩子弄了半天也传不过去参数 (Issue #30)
@li-jin-gou 说实话Post这个api有点反直觉,具体体现在单元测试都没人用,要不要转到hertz下。
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.