-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
handleForwardResponseOptions not called by DefaultHTTPError #1064
Comments
Hm, yea this might be a reasonable proposal, but I don't think we can really change this without breaking users. Might have to be another one for the v2 dust heap 😬. |
If I'm the first one who filed this issue, maybe I can guess they don't use this feature yet? 😂 Otherwise, they must encounter this. @johanbrandhorst |
Nah, this feature is definitely used I'm afraid. I use it myself for many applications and never actually wanted this behaviour. I'm afraid you'll have to overwrite DefaultHTTPError with a function that does what you want :(. |
Yeah, I'm trying. But... Maybe we can provide the other |
I'm hesitant to add more knobs when there is a work around and not a great deal of demand. Does it not work to just assign |
Thanks! It does work. runtime.HTTPError = func(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, w http.ResponseWriter, req *http.Request, err error) {
for _, opt := range mux.GetForwardResponseOptions() {
// The response body (message) is always nil here
if err := opt(ctx, w, nil); err != nil {
return
}
}
runtime.DefaultHTTPError(ctx, mux, marshaler, w, req, err)
} |
handleForwardResponseOptions is called by both ForwardResponseStream and ForwardResponseMessage but not DefaultHTTPError. Is there a reason why? Is it intended?
FYI:
handleForwardResponseServerMetadata
,handleForwardResponseTrailerHeader
andhandleForwardResponseTrailer
are called byForwardResponseMessage
andDefaultHTTPError
.Steps you follow to reproduce the error:
What did you expect to happen instead:
myCallback
gets called on all response-related functions likeForwardResponseMessage
,ForwardResponseStream
andDefaultHTTPError
.What's your theory on why it isn't working:
The text was updated successfully, but these errors were encountered: