-
Notifications
You must be signed in to change notification settings - Fork 357
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
v3.26.5 seems to have broken middleware #197
Comments
In order to support dynamic modification of the request in the request middleware, the user-defined request middleware will be executed first, that is, Two solutions.
package main
import (
"github.com/imroc/req/v3"
)
func LogRequest(rt req.RoundTripper) req.RoundTripFunc {
return func(r *req.Request) (resp *req.Response, err error) {
r.GetClient().GetLogger().Debugf("%s request, path: %s, retry attempt: %d",
r.Method,
r.URL.RequestURI(),
r.RetryAttempt,
)
return rt.RoundTrip(r)
}
}
func main() {
c := req.C().EnableDebugLog().WrapRoundTripFunc(LogRequest)
c.R().MustGet("https://httpbin.org/get")
}
package main
import (
"github.com/imroc/req/v3"
"net/url"
)
func LogRequest(c *req.Client, r *req.Request) error {
u, err := url.Parse(r.RawURL)
if err != nil {
return err
}
c.GetLogger().Debugf("%s request, path: %s, retry attempt: %d",
r.Method,
u.RequestURI(),
r.RetryAttempt,
)
return nil
}
func main() {
c := req.C().EnableDebugLog().OnBeforeRequest(LogRequest)
c.R().MustGet("https://httpbin.org/get")
} |
Thanks for the workarounds. This is a massive breaking change and perhaps should have been more than a patch version bump. |
You're right, but the version has been released, I will pay attention next time, thanks |
I have middleware defined like this:
and then used like this:
When I request something I get:
It seems to be something that changed here: 2522eb2
Reverting back to v3.26.4 fixes the issue.
Any ideas how to get around this? Thanks.
The text was updated successfully, but these errors were encountered: