Route.d.ts 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import { HTTPMethod } from './utils/constants.js';
  2. import { Handler, HandlerObject, MatchCallback } from './_types.js';
  3. import './_version.js';
  4. /**
  5. * A `Route` consists of a pair of callback functions, "match" and "handler".
  6. * The "match" callback determine if a route should be used to "handle" a
  7. * request by returning a non-falsy value if it can. The "handler" callback
  8. * is called when there is a match and should return a Promise that resolves
  9. * to a `Response`.
  10. *
  11. * @memberof module:workbox-routing
  12. */
  13. declare class Route {
  14. handler: HandlerObject;
  15. match: MatchCallback;
  16. method: HTTPMethod;
  17. /**
  18. * Constructor for Route class.
  19. *
  20. * @param {module:workbox-routing~matchCallback} match
  21. * A callback function that determines whether the route matches a given
  22. * `fetch` event by returning a non-falsy value.
  23. * @param {module:workbox-routing~handlerCallback} handler A callback
  24. * function that returns a Promise resolving to a Response.
  25. * @param {string} [method='GET'] The HTTP method to match the Route
  26. * against.
  27. */
  28. constructor(match: MatchCallback, handler: Handler, method?: HTTPMethod);
  29. }
  30. export { Route };