You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some use cases, we need to able to return image responses as mocks. Like GET.json or GET.xml, GET.jpeg should be returned for an image request. There are some tricky parts for this:
For response type, we have auto type that is checking request content-type header and falls-back to json. But for images we should check mock files for this path in any case for image mock files.
Respect to wildcard support(Fixing wildcard matcher #25), checking all possible mock files will be a bit more complex.
We should able to extend this approach for other type of responses. (Video, yaml etc.)
So idea is:
If request is GET /path with accept type application/json we should only check path/GET.json
Request method
Request path
Accept type
Mock file to be checked
GET
/path
application/json
path/GET.json
GET
/path
application/xml
path/GET.xml
GET
/path
image/*
path/GET.(jpeg|gif|png...)
GET
/path
*/*
path/GET.(json|xml|jpeg|gif|png...)
* Custom middlewares should have priority in any case
** If there is no prefered accept type and if there is a json mock file, it should be prioritised
For some use cases, we need to able to return image responses as mocks. Like
GET.jsonorGET.xml,GET.jpegshould be returned for an image request. There are some tricky parts for this:autotype that is checking request content-type header and falls-back to json. But for images we should check mock files for this path in any case for image mock files.So idea is:
GET /pathwith accept typeapplication/jsonwe should only checkpath/GET.json* Custom middlewares should have priority in any case
** If there is no prefered accept type and if there is a json mock file, it should be prioritised