mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-20 13:27:51 +02:00
server: emit default values in JSON
Fixes #208 by always rendering the default values in a JSON response, even if they are "falsey" in the RPC message.
This commit is contained in:
parent
5cf3c1a4e8
commit
f163ac85d8
1 changed files with 13 additions and 1 deletions
14
server.go
14
server.go
|
|
@ -195,11 +195,23 @@ func (s *Server) Start() error {
|
|||
s.cfg.RPCListen)
|
||||
}
|
||||
|
||||
// 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,
|
||||
},
|
||||
)
|
||||
|
||||
// We'll also create and start an accompanying proxy to serve
|
||||
// clients through REST.
|
||||
var ctx context.Context
|
||||
ctx, s.restCancel = context.WithCancel(context.Background())
|
||||
mux := proxy.NewServeMux()
|
||||
mux := proxy.NewServeMux(customMarshalerOption)
|
||||
proxyOpts := []grpc.DialOption{
|
||||
grpc.WithTransportCredentials(*restClientCreds),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue