-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Gateway how to add data head for response body? #3858
Comments
Reference test cases, maybe you can use httpx.OkJson(w, wrappedResp) replace w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(wrappedResp) |
Reference test cases, maybe you can use httpx.OkJson(w, wrappedResp) replace w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(wrappedResp) |
Thanks. I hope to achieve the goal without using "server.Use(wrapResponse)", which is a non-elegant way to implement it. |
@eyjian problem solved? |
Thank you, it's a temporary solution, but it's not elegant and not a satisfactory way. In addition, I hope that the gateway will not be unable to start because a certain service is not started. This is unreasonable. Just because a service cannot start, the gateway cannot start. This is a big problem. The solution is as follows: |
same problem |
Add:
for success response body.
Add:
for fail response body.
httpx.SetErrorHandlerCtx supports fail response, but httpx.SetOkHandler does not work.
The following approach works with middleware, but is inelegant:
@kevwan @gongluck @kesonan Thanks.
The text was updated successfully, but these errors were encountered: