Skip to content
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

[ProtoBuf Render] why not use Data proto.Message directly #4165

Open
cruvie opened this issue Feb 25, 2025 · 1 comment
Open

[ProtoBuf Render] why not use Data proto.Message directly #4165

cruvie opened this issue Feb 25, 2025 · 1 comment

Comments

@cruvie
Copy link

cruvie commented Feb 25, 2025

just a question
render/protobuf.go

type ProtoBuf struct {
	Data any
}

var protobufContentType = []string{"application/x-protobuf"}

// Render (ProtoBuf) marshals the given interface object and writes data with custom ContentType.
func (r ProtoBuf) Render(w http.ResponseWriter) error {
	r.WriteContentType(w)

	bytes, err := proto.Marshal(r.Data.(proto.Message))

why not use proto.Message for Data directly?

type ProtoBuf struct {
	Data proto.Message
}
.....
	bytes, err := proto.Marshal(r.Data)
@hubeoo
Copy link

hubeoo commented Feb 27, 2025

Consistent with other "Render " in interface design

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

No branches or pull requests

2 participants