Constructor

ExpressRoute

new ExpressRoute(input)

Constructor for ExpressRoute.

Parameter

input

Object

Extends
Route

Examples

// Any same-origin requests that start with /path/to and end with one
// additional path segment will match this route, with the last path
// segment passed along to the handler via params.file.
const route = new workbox.routing.ExpressRoute({
  path: '/path/to/:file',
  handler: ({event, params}) => {
    // params.file will be set based on the request URL that matched.
    return caches.match(params.file);
  },
});

const router = new workbox.routing.Router();
router.registerRoute({route});
// Any cross-origin requests for https://example.com will match this route.
const route = new workbox.routing.ExpressRoute({
  path: 'https://example.com/path/to/:file',
  handler: ({event}) => return caches.match(event.request),
});

const router = new workbox.routing.Router();
router.registerRoute({route});