@@ -432,12 +432,14 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
432432 i .serveCAR (r .Context (), w , r , resolvedPath , contentPath , carVersion , begin )
433433 return
434434 case "application/vnd.ipld.dag-json" :
435+ case "application/json" :
435436 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 ))
437438 return
438439 case "application/vnd.ipld.dag-cbor" :
440+ case "application/cbor" :
439441 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 ))
441443 return
442444 default : // catch-all for unsuported application/vnd.*
443445 err := fmt .Errorf ("unsupported format %q" , responseFormat )
@@ -870,16 +872,22 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string]
870872 return "application/vnd.ipld.car" , nil , nil
871873 case "dag-json" :
872874 return "application/vnd.ipld.dag-json" , nil , nil
875+ case "json" :
876+ return "application/json" , nil , nil
873877 case "dag-cbor" :
874878 return "application/vnd.ipld.dag-cbor" , nil , nil
879+ case "cbor" :
880+ return "application/cbor" , nil , nil
875881 }
876882 }
877883 // Browsers and other user agents will send Accept header with generic types like:
878884 // Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
879885 // We only care about explciit, vendor-specific content-types.
880886 for _ , accept := range r .Header .Values ("Accept" ) {
881887 // 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" ) {
883891 mediatype , params , err := mime .ParseMediaType (accept )
884892 if err != nil {
885893 return "" , nil , err
0 commit comments