openformation / strawman

A Deno-based service virtualization solution

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add `Content-Type` filters, so that certain binary formats do not end up as plain text when snapshotted.

grebaldi opened this issue · comments

depends on: #8

Currently, any response coming from a server is treated like a text response.

This isn't optimal for binary formats like images.

It would be great, if those responses would be filtered through a Strategy-like Content-Type class that decides how the snapshot for a speficic Content-Type will be built.

For text responses, the default behavior of saving the snapshot inline with the template file will suffice.

For image responses, the image should be saved to an image file and the reponse template should stream that image file as the response body.

Content-Type strategies should be configurable via manifest (see: #8):

export const manifest: StrawmanManifest = {
  responses: {
    contentTypes: {
        "image/jpeg": new BinaryContentType({ extension: "jpeg" })
    }
  }
}