Last active
March 7, 2017 10:06
-
-
Save amahdy/43a8f528b6ae9f6de1e95f3f3cb5616c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class MyUIServlet extends VaadinServlet { | |
@Override | |
protected void service(HttpServletRequest request, HttpServletResponse response) | |
throws ServletException, IOException { | |
String pathInfo = request.getPathInfo(); | |
if (pathInfo.endsWith("sw.js")) { | |
try (InputStream in = getClass().getResourceAsStream("/sw.js")) { | |
if (in == null) { | |
response.sendError(404); | |
return; | |
} | |
response.setContentType("application/javascript"); | |
OutputStream out = response.getOutputStream(); | |
IOUtils.copy(in, out); | |
in.close(); | |
out.close(); | |
} | |
} else { | |
super.service(request, response); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment