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 13, 2022
1 parent 7fc6410 commit 48a2313
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 48a2313

Please sign in to comment.