-
Hi! I'm trying to use *request.RawRequest in OnBeforeRequest middleware but it's always empty This is how I'm doing a request (not much going on here) request := SomeStruct{}
resp, err := resty.R().SetContext(ctx).SetBody(request).Post(urlString) *request.Body has data as expected. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
@konart Typically Also, can you provide a small test case? it will be helpful to demonstrate an issue. |
Beta Was this translation helpful? Give feedback.
-
Hi, i guess i am having the same issue.
request:
and middleware:
So i cannot use RawRequest in Middleware. |
Beta Was this translation helpful? Give feedback.
-
// import "moul.io/http2curl"
client.SetPreRequestHook(func(client *resty.Client, request *http.Request) error {
command, _ := http2curl.GetCurlCommand(request)
fmt.Printf("begin request: %s", command)
return nil
})
client.OnAfterResponse(func(c *resty.Client, resp *resty.Response) error {
fmt.Println("response: ", resp)
return nil
}) work for me |
Beta Was this translation helpful? Give feedback.
-
Hi, everyone. We could use the PreHookRequest instead, as mentioned here. |
Beta Was this translation helpful? Give feedback.
-
I ran into this same problem where Wrong way...
Correct way...
After creating the Resty client the correct way now |
Beta Was this translation helpful? Give feedback.
Also see: #408 and commit c6b83fa