Skip to content

Commit

Permalink
feat: allow json and cbor data types too
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Oct 11, 2022
1 parent f954ee0 commit 66a9f51
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,25 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
carVersion := formatParams["version"]
i.serveCAR(r.Context(), w, r, resolvedPath, contentPath, carVersion, begin)
return
case "application/vnd.ipld.dag-json", "application/json":
case "application/json":
if resolvedPath.Cid().Prefix().Codec == uint64(mc.Json) {
logger.Debugw("serving json", "path", contentPath)
i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat, uint64(mc.Json))
return
}
fallthrough
case "application/vnd.ipld.dag-json":
logger.Debugw("serving dag-json", "path", contentPath)
i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat, uint64(mc.DagJson))
return
case "application/vnd.ipld.dag-cbor", "application/cbor":
case "application/cbor":
if resolvedPath.Cid().Prefix().Codec == uint64(mc.Cbor) {
logger.Debugw("serving cbor", "path", contentPath)
i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat, uint64(mc.Cbor))
return
}
fallthrough
case "application/vnd.ipld.dag-cbor":
logger.Debugw("serving dag-cbor", "path", contentPath)
i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat, uint64(mc.DagCbor))
return
Expand Down

0 comments on commit 66a9f51

Please sign in to comment.