Skip to content
Snippets Groups Projects
Commit 38c94de8 authored by Lange, Dr. Herbert's avatar Lange, Dr. Herbert
Browse files

send correct mime type for static files

parent 60a73b60
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,19 @@ public class Static {
public Response getStatic(@PathParam("staticFile") String fileName) {
logger.info("Loading file " + fileName);
try {
return Response.ok(this.getClass().getModule().getResourceAsStream("static/" + fileName).readAllBytes()).build();
String type;
if (fileName.toLowerCase().endsWith("js")) {
type = "application/javascript";
}
else if (fileName.toLowerCase().endsWith("css")) {
type = "text/css";
}
else {
type = "application/octet-stream";
}
return Response.ok(this.getClass().getModule().getResourceAsStream("static/" + fileName).readAllBytes())
.type(type)
.build();
}
catch (IOException e) {
return Response.status(500, "Error loading resource").build();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment