Since the tests, don't include the comment, here's the result:
// Service is the admin service interface.
type Service interface {
// Assets implements assets.
// If body implements [io.WriterTo], that implementation will be used instead.
// Consider [goa.design/goa/v3/pkg.SkipResponseWriter] to adapt existing
// implementations.
Assets(context.Context, *AuthenticatedRequest) (res *CustomJSONResponse, body io.ReadCloser, err error)
}
Note: Tried this out in one of my projects and added WriterToFunc to the exported API as well, since I found myself wanting it for most of the handlers I was rewriting. Allows you to use a closure and avoids needing to manually keep track of bytes written, while still preserving the io.WriterTo interface. Useful for times when you're passing the writer to something else that doesn't report how many bytes are written like json.Encoder or xml.Encoder.
Thank you for the great contribution! I was wondering if you'd be up to updating the upload_download example to take advantage of this new feature after we release it?
Implementation for #3522
Since the tests, don't include the comment, here's the result:
Note: Tried this out in one of my projects and added
WriterToFunc
to the exported API as well, since I found myself wanting it for most of the handlers I was rewriting. Allows you to use a closure and avoids needing to manually keep track of bytes written, while still preserving theio.WriterTo
interface. Useful for times when you're passing the writer to something else that doesn't report how many bytes are written likejson.Encoder
orxml.Encoder
.