github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/compute/publicapi/server.go (about)

     1  package publicapi
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/filecoin-project/bacalhau/pkg/model"
     7  	"github.com/filecoin-project/bacalhau/pkg/publicapi"
     8  )
     9  
    10  const APIPrefix = "compute/"
    11  
    12  type ComputeAPIServerParams struct {
    13  	APIServer          *publicapi.APIServer
    14  	DebugInfoProviders []model.DebugInfoProvider
    15  }
    16  
    17  type ComputeAPIServer struct {
    18  	apiServer          *publicapi.APIServer
    19  	debugInfoProviders []model.DebugInfoProvider
    20  }
    21  
    22  func NewComputeAPIServer(params ComputeAPIServerParams) *ComputeAPIServer {
    23  	return &ComputeAPIServer{
    24  		apiServer:          params.APIServer,
    25  		debugInfoProviders: params.DebugInfoProviders,
    26  	}
    27  }
    28  
    29  func (s *ComputeAPIServer) RegisterAllHandlers() error {
    30  	handlerConfigs := []publicapi.HandlerConfig{
    31  		{URI: "/" + APIPrefix + "debug", Handler: http.HandlerFunc(s.debug)},
    32  	}
    33  	return s.apiServer.RegisterHandlers(handlerConfigs...)
    34  }