I am creating some kind of proxy server with Restlet, however I have a problem that there is no automatic way to determine MediaType
based on client request.
Here is my code:
Representation entity = null; entity.setMediaType(processMediaType(path));
To process media type:
private MediaType processMediaType(String path){ MediaType type = MediaType.ALL; if(path.endsWith("html")){ type = MediaType.TEXT_HTML; } else if (path.endsWith("css")) { type = MediaType.TEXT_CSS; } else if (path.endsWith("js")) { type = MediaType.TEXT_JAVASCRIPT; } else if (path.endsWith("txt")) { type = MediaType.TEXT_PLAIN; } else if (path.endsWith("jpg")){ type = MediaType.IMAGE_JPEG; } else if (path.endsWith("png")){ type = MediaType.IMAGE_PNG; } return type; }
I was wondering if MediaType can be autoframed (or by getting MediaType from a query that didn't work for me) from the query, so I wonβt have to do these if-else statements, which is very limited in catching different types of media.
source share