mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-26 02:56:30 +02:00
rpcserver+lnrpc: register REST subservers with root server
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
fmt "fmt"
|
||||
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"google.golang.org/grpc"
|
||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||
@@ -91,6 +92,28 @@ func (c *Handler) RegisterWithRootServer(grpcServer *grpc.Server) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterWithRestServer will be called by the root REST mux to direct a sub
|
||||
// RPC server to register itself with the main REST mux server. Until this is
|
||||
// called, each sub-server won't be able to have requests routed towards it.
|
||||
//
|
||||
// NOTE: This is part of the lnrpc.SubServer interface.
|
||||
func (c *Handler) RegisterWithRestServer(ctx context.Context,
|
||||
mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
|
||||
|
||||
// We make sure that we register it with the main REST server to ensure
|
||||
// all our methods are routed properly.
|
||||
err := RegisterWatchtowerHandlerFromEndpoint(ctx, mux, dest, opts)
|
||||
if err != nil {
|
||||
log.Errorf("Could not register Watchtower REST server "+
|
||||
"with root REST server: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("Watchtower REST server successfully registered with " +
|
||||
"root REST server")
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddTower adds a new watchtower reachable at the given address and considers
|
||||
// it for new sessions. If the watchtower already exists, then any new addresses
|
||||
// included will be considered when dialing it for session negotiations and
|
||||
|
Reference in New Issue
Block a user