Choosing an Accept MIME type to return a sequence of alike objects

Viewed 10

I'm building a microservice which, in theory, should be capable of returning a list of objects of content type determined by the client request's Accept header.

This was all well and good for a previous service which returned individual images: image/jpeg gets JPEG-encoded responses, image/png gets PNG, etc etc.

Now though, we're looking for each response to be a sequence of images... And I was surprised from reading around, that I couldn't really find conventions for such "composite" MIME types?

The exact response structure is not fixed: For example we could return anything from a zip archive to a RecordIO sequence or whatever else, to wrap the list... But is there a particular approach that would have nicely conventional support for specifying the inner format within the Accept header?

Neither application/zip nor application/recordio communicate anything about the underlying objects. image/jpeg implies a single image object... Maybe this is an obvious use case for multipart/??? and I'm just not familiar enough with that?

The service is implemented in Python, and clients are likely to be Python or JS/TS. Heck, we could even do something like application/x-zip-of-txt-base64-encoded-pngs if we really wanted to... It just feels like there should be a "right" way!

0 Answers
Related