createHandlerBoundToURL.js 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. /*
  2. Copyright 2019 Google LLC
  3. Use of this source code is governed by an MIT-style
  4. license that can be found in the LICENSE file or at
  5. https://opensource.org/licenses/MIT.
  6. */
  7. import { getOrCreatePrecacheController } from './utils/getOrCreatePrecacheController.js';
  8. import './_version.js';
  9. /**
  10. * Helper function that calls
  11. * {@link PrecacheController#createHandlerBoundToURL} on the default
  12. * {@link PrecacheController} instance.
  13. *
  14. * If you are creating your own {@link PrecacheController}, then call the
  15. * {@link PrecacheController#createHandlerBoundToURL} on that instance,
  16. * instead of using this function.
  17. *
  18. * @param {string} url The precached URL which will be used to lookup the
  19. * `Response`.
  20. * @param {boolean} [fallbackToNetwork=true] Whether to attempt to get the
  21. * response from the network if there's a precache miss.
  22. * @return {module:workbox-routing~handlerCallback}
  23. *
  24. * @memberof module:workbox-precaching
  25. */
  26. function createHandlerBoundToURL(url) {
  27. const precacheController = getOrCreatePrecacheController();
  28. return precacheController.createHandlerBoundToURL(url);
  29. }
  30. export { createHandlerBoundToURL };