package api import ( "net/http" "forge.cadoles.com/Cadoles/emissary/internal/datastore" "github.com/pkg/errors" "gitlab.com/wpetit/goweb/api" "gitlab.com/wpetit/goweb/logger" ) func (m *Mount) getSpecDefinition(w http.ResponseWriter, r *http.Request) { specDefName, specDefVersion, ok := getSpecDefinitionNameAndVersion(w, r) if !ok { return } ctx := r.Context() specDef, err := m.specDefRepo.Get( ctx, specDefName, specDefVersion, ) if err != nil { if errors.Is(err, datastore.ErrNotFound) { api.ErrorResponse(w, http.StatusNotFound, ErrCodeNotFound, nil) return } err = errors.WithStack(err) logger.Error(ctx, "could not get agent", logger.CapturedE(err)) api.ErrorResponse(w, http.StatusInternalServerError, ErrCodeUnknownError, nil) return } api.DataResponse(w, http.StatusOK, struct { SpecDefinition *datastore.SpecDefinition `json:"specDefinition"` }{ SpecDefinition: specDef, }) }