github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/publicapi/endpoint_id.go (about) 1 package publicapi 2 3 import ( 4 "encoding/json" 5 "net/http" 6 ) 7 8 // id godoc 9 // 10 // @ID id 11 // @Summary Returns the id of the host node. 12 // @Tags Utils 13 // @Produce text/plain 14 // @Success 200 {object} string 15 // @Failure 500 {object} string 16 // @Router /id [get] 17 func (apiServer *APIServer) id(res http.ResponseWriter, _ *http.Request) { 18 res.WriteHeader(http.StatusOK) 19 err := json.NewEncoder(res).Encode(apiServer.host.ID().String()) 20 if err != nil { 21 http.Error(res, err.Error(), http.StatusInternalServerError) 22 return 23 } 24 }