@@ -432,12 +432,14 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
432
432
i .serveCAR (r .Context (), w , r , resolvedPath , contentPath , carVersion , begin )
433
433
return
434
434
case "application/vnd.ipld.dag-json" :
435
+ case "application/json" :
435
436
logger .Debugw ("serving dag-json" , "path" , contentPath )
436
- i .serveJSON (r .Context (), w , r , resolvedPath , begin , "application/vnd.ipld.dag-json" , uint64 (mc .DagJson ))
437
+ i .serveCodec (r .Context (), w , r , resolvedPath , contentPath , begin , responseFormat , uint64 (mc .DagJson ))
437
438
return
438
439
case "application/vnd.ipld.dag-cbor" :
440
+ case "application/cbor" :
439
441
logger .Debugw ("serving dag-cbor" , "path" , contentPath )
440
- i .serveJSON (r .Context (), w , r , resolvedPath , begin , "application/vnd.ipld.dag-cbor" , uint64 (mc .DagCbor ))
442
+ i .serveCodec (r .Context (), w , r , resolvedPath , contentPath , begin , responseFormat , uint64 (mc .DagCbor ))
441
443
return
442
444
default : // catch-all for unsuported application/vnd.*
443
445
err := fmt .Errorf ("unsupported format %q" , responseFormat )
@@ -870,16 +872,22 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string]
870
872
return "application/vnd.ipld.car" , nil , nil
871
873
case "dag-json" :
872
874
return "application/vnd.ipld.dag-json" , nil , nil
875
+ case "json" :
876
+ return "application/json" , nil , nil
873
877
case "dag-cbor" :
874
878
return "application/vnd.ipld.dag-cbor" , nil , nil
879
+ case "cbor" :
880
+ return "application/cbor" , nil , nil
875
881
}
876
882
}
877
883
// Browsers and other user agents will send Accept header with generic types like:
878
884
// Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
879
885
// We only care about explciit, vendor-specific content-types.
880
886
for _ , accept := range r .Header .Values ("Accept" ) {
881
887
// respond to the very first ipld content type
882
- if strings .HasPrefix (accept , "application/vnd.ipld" ) {
888
+ if strings .HasPrefix (accept , "application/vnd.ipld" ) ||
889
+ strings .HasPrefix (accept , "application/json" ) ||
890
+ strings .HasPrefix (accept , "application/cbor" ) {
883
891
mediatype , params , err := mime .ParseMediaType (accept )
884
892
if err != nil {
885
893
return "" , nil , err
0 commit comments