Skip to content

Do not write HTTP headers with SkipResponseBodyEncodeDecode #3695

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

Merged
merged 1 commit into from
Apr 11, 2025

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