registerRoute.d.ts 1.1 KB

12345678910111213141516171819202122232425
  1. import { Route } from './Route.js';
  2. import { HTTPMethod } from './utils/constants.js';
  3. import { Handler, MatchCallback } from './_types.js';
  4. import './_version.js';
  5. /**
  6. * Easily register a RegExp, string, or function with a caching
  7. * strategy to a singleton Router instance.
  8. *
  9. * This method will generate a Route for you if needed and
  10. * call [registerRoute()]{@link module:workbox-routing.Router#registerRoute}.
  11. *
  12. * @param {RegExp|string|module:workbox-routing.Route~matchCallback|module:workbox-routing.Route} capture
  13. * If the capture param is a `Route`, all other arguments will be ignored.
  14. * @param {module:workbox-routing~handlerCallback} [handler] A callback
  15. * function that returns a Promise resulting in a Response. This parameter
  16. * is required if `capture` is not a `Route` object.
  17. * @param {string} [method='GET'] The HTTP method to match the Route
  18. * against.
  19. * @return {module:workbox-routing.Route} The generated `Route`(Useful for
  20. * unregistering).
  21. *
  22. * @memberof module:workbox-routing
  23. */
  24. declare function registerRoute(capture: RegExp | string | MatchCallback | Route, handler?: Handler, method?: HTTPMethod): Route;
  25. export { registerRoute };