rpcserver+lnrpc: register REST subservers with root server
This commit is contained in:
11 files changed
+224
-4
No files matched your search
@@ -8,6 +8,7 @@ import (
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/lightningnetwork/lnd/autopilot"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"google.golang.org/grpc"
|
||||
@@ -129,6 +130,28 @@ func (s *Server) 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 (s *Server) 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 := RegisterAutopilotHandlerFromEndpoint(ctx, mux, dest, opts)
|
||||
if err != nil {
|
||||
log.Errorf("Could not register Autopilot REST server "+
|
||||
"with root REST server: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("Autopilot REST server successfully registered with " +
|
||||
"root REST server")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Status returns the current status of the autopilot agent.
|
||||
//
|
||||
// NOTE: Part of the AutopilotServer interface.
|
||||
|
||||
Reference in new issue
Block a user