Skip to content

Route ​

Class @vite-pwa/workbox-swkit/routing

A Route consists of a pair of callback functions, "match" and "handler". The "match" callback determine if a route should be used to "handle" a request by returning a non-falsy value if it can. The "handler" callback is called when there is a match and should return a Promise that resolves to a Response.

Constructor ​

ts
new Route(match: RouteMatchCallback, handler: RouteHandler, method?: HTTPMethod)

Constructor for Route class.

Parameters

  • match – A callback function that determines whether the route matches a given fetch event by returning a non-falsy value.

  • handler – A callback function that returns a Promise resolving to a Response.

  • method – The HTTP method to match the Route against.

Properties ​

PropertyTypeDefaultDescription
catchHandler?RouteHandlerObject
handlerRouteHandlerObject
matchRouteMatchCallback
methodHTTPMethod

Methods ​

setCatchHandler() ​

ts
setCatchHandler(handler: RouteHandler): void

Parameters

  • handler – A callback function that returns a Promise resolving to a Response

Released under the MIT License.