Rust Warp如何通过添加额外的标头将JSON有效载荷委托给另一个URL的请求?
如何添加额外的标头,例如access_token:jshaj_some_really_long_token
,还将content-type设置为content> content-type:application/json
in Warp post post呼叫吗?
方案详细:
- 我想使用纱创建API,说终点是
https://example.com/orders
- type是帖子,需要有效载荷=>
'{“ Myid”:12,“ Price”:23.2,“ Transaction”:“ Buy”,“ dentity”:10}'
- 现在我想使用
reqwest
或构建warp
http
客户端的任何内容都将请求发送到另一个服务器端点SAIS SAIS SAI SAI SAShttps://api.example.com/orders.com/orders
带有上述后有效负载,但使用新标头content-type:application/json
和access-token:jshaj_some_really_long_token
,
如果有一些使用Warp and Reqwest的示例,请共享用于发布请求。目前,我正在引用 this
How to add extra header like access_token : jshaj_some_really_long_token
and also set content-type to Content-Type: application/json
in warp post call?
Scenario in detail:
- I want to create API using warp say the end point is
https://example.com/orders
- The type is post which needs a payload =>
'{ "myid" : 12 , "price" : 23.2, "transaction" : "buy", "quantity" : 10 }'
- Now I want to use
reqwest
or any in builtwarp
http
client to send a request to another server endpoint sayhttps://api.example.com/orders
with the above post payload but with the new header which isContent-Type: application/json
andaccess-token: jshaj_some_really_long_token
Please do share if there are some examples which are using warp and reqwest for post requests. Currently I am referring this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
warp-reverse-reverse-proxy
那个(在这里维护器:))
您必须在内部组合实用程序,以根据示例修改您的需求:
请注意,请求的转发是由LIB完成的,如果您实际想要示例,则可以检查源代码调查如何完成。
You can use the
warp-reverse-proxy
crate for that (maintainer here :) )You would have to compose the utilities inside to modify what you need as per the example:
Notice that the forwarding of the request is done by the lib, if you actually want examples you can check the source code to investigate how it is done.