Skip to content

Commit 7916b03

Browse files
srikrsnaachew22
authored andcommitted
Added camelCase Example
1 parent 565b481 commit 7916b03

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/_docs/customizingyourgateway.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ order: 101
77
# Customizing your gateway
88

99
## Message serialization
10+
### Custom serializer
1011

1112
You might want to serialize request/response messages in MessagePack instead of JSON, for example.
1213

@@ -20,6 +21,13 @@ You might want to serialize request/response messages in MessagePack instead of
2021

2122
You can see [the default implementation for JSON](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/marshal_jsonpb.go) for reference.
2223

24+
### Using camelCase for JSON
25+
26+
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,
27+
```go
28+
mux := runtime.NewServeMux(runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{OrigName:false}))
29+
```
30+
2331
## Mapping from HTTP request headers to gRPC client metadata
2432
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.
2533

0 commit comments

Comments
 (0)