Merge pull request #3965 from guggero/rest-api-falsey
rpcserver: instruct REST marshaler to emit default values
This commit is contained in:
commit
04c3998f4b
13
rpcserver.go
13
rpcserver.go
@ -750,6 +750,17 @@ func (r *rpcServer) Start() error {
|
||||
}
|
||||
}
|
||||
|
||||
// The default JSON marshaler of the REST proxy only sets OrigName to
|
||||
// true, which instructs it to use the same field names as specified in
|
||||
// the proto file and not switch to camel case. What we also want is
|
||||
// that the marshaler prints all values, even if they are falsey.
|
||||
customMarshalerOption := proxy.WithMarshalerOption(
|
||||
proxy.MIMEWildcard, &proxy.JSONPb{
|
||||
OrigName: true,
|
||||
EmitDefaults: true,
|
||||
},
|
||||
)
|
||||
|
||||
// Finally, start the REST proxy for our gRPC server above. We'll ensure
|
||||
// we direct LND to connect to its loopback address rather than a
|
||||
// wildcard to prevent certificate issues when accessing the proxy
|
||||
@ -757,7 +768,7 @@ func (r *rpcServer) Start() error {
|
||||
//
|
||||
// TODO(roasbeef): eventually also allow the sub-servers to themselves
|
||||
// have a REST proxy.
|
||||
mux := proxy.NewServeMux()
|
||||
mux := proxy.NewServeMux(customMarshalerOption)
|
||||
|
||||
err := lnrpc.RegisterLightningHandlerFromEndpoint(
|
||||
context.Background(), mux, r.restProxyDest,
|
||||
|
Loading…
Reference in New Issue
Block a user