Skip to content

Commit

Permalink
fix: add missing traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Oct 21, 2022
1 parent a5c2e13 commit 8b5f5e0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/corehttp/gateway_handler_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/ipfs/kubo/tracing"
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/multicodec"
"github.com/ipld/go-ipld-prime/traversal"
mc "github.com/multiformats/go-multicodec"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -95,6 +96,16 @@ func (i *gatewayHandler) serveCodec(ctx context.Context, w http.ResponseWriter,
}
finalNode := universal.(ipld.Node)

if len(resolvedPath.Remainder()) > 0 {
remainderPath := ipld.ParsePath(resolvedPath.Remainder())

finalNode, err = traversal.Get(finalNode, remainderPath)
if err != nil {
webError(w, err.Error(), err, http.StatusInternalServerError)
return
}
}

// Otherwise convert it using the last codec of the list.
encoder, err := multicodec.LookupEncoder(codecs[len(codecs)-1])
if err != nil {
Expand Down

0 comments on commit 8b5f5e0

Please sign in to comment.