From 7916b03771e9edb045fcfc7db5f516f8b6a29c39 Mon Sep 17 00:00:00 2001 From: Sri Krishna Paritala Date: Mon, 10 Sep 2018 17:13:36 +0530 Subject: [PATCH] Added camelCase Example --- docs/_docs/customizingyourgateway.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/_docs/customizingyourgateway.md b/docs/_docs/customizingyourgateway.md index 20c747f2771..a8071cb1741 100644 --- a/docs/_docs/customizingyourgateway.md +++ b/docs/_docs/customizingyourgateway.md @@ -7,6 +7,7 @@ order: 101 # Customizing your gateway ## Message serialization +### Custom serializer You might want to serialize request/response messages in MessagePack instead of JSON, for example. @@ -20,6 +21,13 @@ You might want to serialize request/response messages in MessagePack instead of You can see [the default implementation for JSON](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/marshal_jsonpb.go) for reference. +### Using camelCase for JSON + +The protocol buffer compiler generates camelCase JSON tags that can be used with jsonpb package. By default jsonpb Marshaller uses `OrigName: true` which uses the exact case used in the proto files. To use camelCase for the JSON representation, + ```go + mux := runtime.NewServeMux(runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{OrigName:false})) + ``` + ## Mapping from HTTP request headers to gRPC client metadata You might not like [the default mapping rule](http://godoc.org/github.com/grpc-ecosystem/grpc-gateway/runtime#DefaultHeaderMatcher) and might want to pass through all the HTTP headers, for example.