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

Response body as a single field #217

Closed
BrianHicks opened this issue Aug 19, 2016 · 3 comments
Closed

Response body as a single field #217

BrianHicks opened this issue Aug 19, 2016 · 3 comments

Comments

@BrianHicks
Copy link

Part of the API I'm covering needs to be able to return just bytes. Right now I have something similar to the following:

message Content {
  string content = 1;
}

for RPC, that's just fine; the client can unwrap it. However, over HTTP I don't want a wrapping JSON, I only want that content field. Is there a way to specify this in the gateway configuration?

@yugui
Copy link
Member

yugui commented Aug 23, 2016

You can write a custom marshaler to do that.
Also, what grpc-gateway generates is an ordinary HTTP handler in Golang. So you can do whatever you want by wrapping the handler.

@yugui yugui closed this as completed Aug 23, 2016
@BrianHicks
Copy link
Author

Is there documentation or an example of where to put the custom marshaller? It doesn't jump out at me where it should go.

@skylarbpayne
Copy link

Hey @BrianHicks , I see your question was never answered. You can use the WithMarshalerOption in your entry point:

func WithMarshalerOption(mime string, marshaler Marshaler) ServeMuxOption {

Hope that helps :).

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