Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@raphael
Copy link
Member

@raphael raphael commented Apr 11, 2025

Make it possible for user code to write HTTP headers.

Prior to this fix using SkipResponseBodyEncodeDecode would generate the following encoder code:

// EncodeStreamResponse returns an encoder for responses returned by the events
// stream endpoint.
func EncodeStreamResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {
	return func(ctx context.Context, w http.ResponseWriter, v any) error {
		w.WriteHeader(http.StatusOK)
		return nil
	}
}

With this change the function is now:

// EncodeStreamResponse returns an encoder for responses returned by the events
// stream endpoint.
func EncodeStreamResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {
	return func(ctx context.Context, w http.ResponseWriter, v any) error {
		return nil
	}
}

This makes it possible for user code to write custom headers, for example to support SSE.

Make it possible for user code to write HTTP headers.
@raphael raphael enabled auto-merge (squash) April 11, 2025 04:36
@raphael raphael merged commit dd2eff6 into v3 Apr 11, 2025
12 of 13 checks passed
@raphael raphael deleted the fix/response-encoder-template branch April 11, 2025 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant