Skip to content

Commit

Permalink
fix(get dataset): return a datasetRef, not a dataset!
Browse files Browse the repository at this point in the history
Merge pull request #701 from qri-io/getFix
  • Loading branch information
ramfox authored Mar 4, 2019
2 parents 5ad86c0 + 3f56dbb commit 6446e54
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
9 changes: 8 additions & 1 deletion api/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,14 @@ func (h *DatasetHandlers) getHandler(w http.ResponseWriter, r *http.Request) {
util.WriteErrResponse(w, http.StatusInternalServerError, err)
return
}
util.WriteResponse(w, res.Dataset)
ref := repo.DatasetRef{
Peername: res.Dataset.Peername,
ProfileID: profile.ID(res.Dataset.ProfileID),
Name: res.Dataset.Name,
Path: res.Dataset.Path,
Dataset: res.Dataset,
}
util.WriteResponse(w, ref)
}

func (h *DatasetHandlers) diffHandler(w http.ResponseWriter, r *http.Request) {
Expand Down
13 changes: 12 additions & 1 deletion api/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
util "github.com/datatogether/api/apiutil"
"github.com/qri-io/qri/config"
"github.com/qri-io/qri/lib"
"github.com/qri-io/qri/repo"
"github.com/qri-io/qri/repo/profile"
)

// RootHandler bundles handlers that may need to be called
Expand Down Expand Up @@ -62,6 +64,15 @@ func (mh *RootHandler) Handler(w http.ResponseWriter, r *http.Request) {
util.WriteErrResponse(w, http.StatusNotFound, errors.New("cannot find peer dataset"))
return
}
util.WriteResponse(w, res.Dataset)

ref = repo.DatasetRef{
Peername: res.Dataset.Peername,
ProfileID: profile.ID(res.Dataset.ProfileID),
Name: res.Dataset.Name,
Path: res.Dataset.Path,
Dataset: res.Dataset,
}

util.WriteResponse(w, ref)
return
}
Binary file modified api/testdata/api.snapshot
Binary file not shown.

0 comments on commit 6446e54

Please sign in to comment.