refactor: move State server REST registration

This commit moves the registration of the State server with a REST proxy
into the `RegisterWithRestProxy` method in order to keep all the REST
registrations in one place.
This commit is contained in:
Elle Mouton 2023-08-08 11:43:25 +02:00
parent bf5aab9d52
commit b9560b067a
No known key found for this signature in database
GPG Key ID: D7D916376026F177
2 changed files with 10 additions and 8 deletions

9
lnd.go
View File

@ -901,14 +901,7 @@ func startRestProxy(cfg *Config, rpcServer *rpcServer, restDialOpts []grpc.DialO
)
// Register our services with the REST proxy.
err := lnrpc.RegisterStateHandlerFromEndpoint(
ctx, mux, restProxyDest, restDialOpts,
)
if err != nil {
return nil, err
}
err = rpcServer.RegisterWithRestProxy(
err := rpcServer.RegisterWithRestProxy(
ctx, mux, restDialOpts, restProxyDest,
)
if err != nil {

View File

@ -906,6 +906,15 @@ func (r *rpcServer) RegisterWithRestProxy(restCtx context.Context,
return err
}
// Register our State service with the REST proxy.
err = lnrpc.RegisterStateHandlerFromEndpoint(
restCtx, restMux, restProxyDest, restDialOpts,
)
if err != nil {
return err
}
// Register all the subservers with the REST proxy.
for _, subServer := range r.subGrpcHandlers {
err := subServer.RegisterWithRestServer(
restCtx, restMux, restProxyDest, restDialOpts,