@Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { String requestUri = request.getPathInfo(); if (pwaRegistry.getPwaConfiguration().isEnabled()) { if (requestHandlerMap.containsKey(requestUri)) { return requestHandlerMap.get(requestUri) .handleRequest(session,request,response); } else if (requestUri.startsWith("/"+PwaRegistry.WORKBOX_FOLDER)) { // allow only files under workbox_folder String resourceName = PwaRegistry.WORKBOX_FOLDER + requestUri // remove the extra '/' .substring(PwaRegistry.WORKBOX_FOLDER.length() + 1) .replaceAll("/", ""); return handleWorkboxResource(resourceName, response); } } return false; }
.append(" .catch(function() {\n") .append(String.format(" return caches.match('%s');%n", getPwaConfiguration().getOfflinePath())) .append(" })\n );\n }\n });");
/** * Called during initialization to add the request handlers for the service. * Note that the returned list will be reversed so the last handler will be * called first. This enables overriding this method and using add on the * returned list to add a custom request handler which overrides any * predefined handler. * * @return The list of request handlers used by this service. * @throws ServiceException * if a problem occurs when creating the request handlers */ protected List<RequestHandler> createRequestHandlers() throws ServiceException { List<RequestHandler> handlers = new ArrayList<>(); handlers.add(new SessionRequestHandler()); handlers.add(new HeartbeatHandler()); handlers.add(new UidlRequestHandler()); handlers.add(new UnsupportedBrowserHandler()); handlers.add(new StreamRequestHandler()); PwaRegistry pwaRegistry = getPwaRegistry(); if (pwaRegistry != null && pwaRegistry.getPwaConfiguration() .isEnabled()) { handlers.add(new PwaHandler(pwaRegistry)); } return handlers; }
private void init() { if (!pwaRegistry.getPwaConfiguration().isEnabled()) { return; pwaRegistry.getPwaConfiguration().relOfflinePath(), (session, request, response) -> { response.setContentType("text/html"); pwaRegistry.getPwaConfiguration().relManifestPath(), (session, request, response) -> { response.setContentType("application/manifest+json"); pwaRegistry.getPwaConfiguration().relServiceWorkerPath(), (session, request, response) -> { response.setContentType("application/javascript");
PwaConfiguration config = registry.getPwaConfiguration(); if (registry.getPwaConfiguration().isInstallPromptEnabled()) {