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

     1  package publicapi
     2  
     3  import (
     4  	"encoding/json"
     5  	"net/http"
     6  )
     7  
     8  // nodeInfo godoc
     9  //
    10  //	@ID			nodeInfo
    11  //	@Summary	Returns the info of the node.
    12  //	@Tags		Utils
    13  //	@Produce	json
    14  //	@Success	200	{object}	model.NodeInfo
    15  //	@Failure	500	{object}	string
    16  //	@Router		/node_info [get]
    17  func (apiServer *APIServer) nodeInfo(res http.ResponseWriter, req *http.Request) {
    18  	res.WriteHeader(http.StatusOK)
    19  	err := json.NewEncoder(res).Encode(apiServer.nodeInfoProvider.GetNodeInfo(req.Context()))
    20  	if err != nil {
    21  		http.Error(res, err.Error(), http.StatusInternalServerError)
    22  		return
    23  	}
    24  }