Skip to content

Commit 66a9f51

Browse files
committed
feat: allow json and cbor data types too
1 parent f954ee0 commit 66a9f51

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

core/corehttp/gateway_handler.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,25 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
431431
carVersion := formatParams["version"]
432432
i.serveCAR(r.Context(), w, r, resolvedPath, contentPath, carVersion, begin)
433433
return
434-
case "application/vnd.ipld.dag-json", "application/json":
434+
case "application/json":
435+
if resolvedPath.Cid().Prefix().Codec == uint64(mc.Json) {
436+
logger.Debugw("serving json", "path", contentPath)
437+
i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat, uint64(mc.Json))
438+
return
439+
}
440+
fallthrough
441+
case "application/vnd.ipld.dag-json":
435442
logger.Debugw("serving dag-json", "path", contentPath)
436443
i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat, uint64(mc.DagJson))
437444
return
438-
case "application/vnd.ipld.dag-cbor", "application/cbor":
445+
case "application/cbor":
446+
if resolvedPath.Cid().Prefix().Codec == uint64(mc.Cbor) {
447+
logger.Debugw("serving cbor", "path", contentPath)
448+
i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat, uint64(mc.Cbor))
449+
return
450+
}
451+
fallthrough
452+
case "application/vnd.ipld.dag-cbor":
439453
logger.Debugw("serving dag-cbor", "path", contentPath)
440454
i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat, uint64(mc.DagCbor))
441455
return

0 commit comments

Comments
 (0)