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 enumerated values now returned as strings instead of numbers. #186

Closed
rlmcpherson opened this issue Jun 15, 2016 · 2 comments
Closed

Comments

@rlmcpherson
Copy link

Previously, at least on commit id b94f713 (2016-2-18), enumerated values were returned in http responses as numbers. Now they are returned as the strings corresponding to those values. While this is better behavior, it is also a breaking change. Is there any way to disable this behavior while still updating to the latest version of the package? When was this change introduced?

I suspect that this may have to do with the move to jsonpb by default but setting the ServeMux option to use the built-in Marshaler for json does not appear to have any effect. Is there a workaround for this issue?

@yugui
Copy link
Member

yugui commented Jul 11, 2016

You can use a custom instance of JSONPb marshaler and pass it as an option when you instantiate Mux.

m := &runtime.JSONPb{
  OrigName: true,
  EnumsAsInts: true,
}
mux := runtime.NewServeMux(runtime.WithMarshalerOption("application/json", m))
...

@achew22
Copy link
Collaborator

achew22 commented Aug 9, 2016

@rlmcpherson, I'm going to mark this issue as closed. If there is any more information you need, please feel free to reopen it.

@yugui, thank you for getting this one.

@achew22 achew22 closed this as completed Aug 9, 2016
@tamalsaha tamalsaha mentioned this issue Mar 30, 2017
1 task
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

3 participants