kratos icon indicating copy to clipboard operation
kratos copied to clipboard

`http.Client.Do()` not support `WithMiddleware()` option

Open ionling opened this issue 2 years ago • 2 comments

https://github.com/go-kratos/kratos/blob/de0e4e222832ff076734ebe50a7df9de46e4ae43/transport/http/client.go#L272

After I looked the code, I found it's hard to implement this feature, as client.Invoke() use middleware.Hanler (type Handler func(ctx context.Context, req interface{}) (interface{}, error)) model, but client.Do() use the standard http lib model (func (c *Client) Do(req *Request) (*Response, error)). It's impossible to convert client.Do() model to middleware.Hanler model.

Does anyone have better ideas?

ionling avatar Jul 21 '22 08:07 ionling

I'll take this in these days 这几天我来搞一下这个吧

wang-tsh avatar Aug 24 '22 00:08 wang-tsh

@tonybase plz review it @shenqidebaozi plz review it

wang-tsh avatar Aug 25 '22 06:08 wang-tsh

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Is there any update on this question?

kratos-ci-bot avatar Apr 11 '23 08:04 kratos-ci-bot

Hi, @ionling! I'm Dosu, and I'm helping the kratos team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, the issue is that the http.Client.Do() method does not support the WithMiddleware() option in the Kratos framework. You were seeking suggestions for a solution. There have been recent comments from users wang-tsh and kratos-ci-bot, but there haven't been any updates on the issue yet.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the kratos repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the kratos project!

dosubot[bot] avatar Nov 03 '23 16:11 dosubot[bot]

According the code: https://github.com/go-kratos/kratos/blob/3fc8fb7a0a0bd35f7f934cbb7ca26814cbc49132/transport/http/client.go#L270

it is still relevant to the latest version of the kratos repository.

ionling avatar Nov 06 '23 09:11 ionling

@kratos-ci-bot Could you please help @ionling with this issue? They have indicated that the issue is still relevant to the latest version of the kratos repository. Thank you!

dosubot[bot] avatar Nov 06 '23 09:11 dosubot[bot]

Hi, @ionling,

I'm helping the Kratos team manage their backlog and am marking this issue as stale. It seems like you're struggling to implement the WithMiddleware() option in http.Client.Do() in the Kratos framework due to a mismatch between the client.Invoke() and client.Do() models. There have been recent comments from users wang-tsh and kratos-ci-bot, and I see that you've confirmed that the issue is still relevant to the latest version of the Kratos repository.

Could you please let us know if the issue is still relevant to the latest version of the Kratos repository? If it is, please provide any additional context or updates. Otherwise, feel free to close the issue yourself, or the issue will be automatically closed in 7 days.

Thank you for your understanding and cooperation. Your input is valuable in helping us maintain the repository effectively.

I (Dosu)

dosubot[bot] avatar Feb 05 '24 16:02 dosubot[bot]