English
Route
Class @vite-pwa/workbox-swkit/routingA 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 givenfetchevent 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
| Property | Type | Default | Description |
|---|---|---|---|
catchHandler? | RouteHandlerObject | ||
handler | RouteHandlerObject | ||
match | RouteMatchCallback | ||
method | HTTPMethod |
Methods
setCatchHandler()
ts
setCatchHandler(handler: RouteHandler): voidParameters
handler– A callback function that returns a Promise resolving to a Response