What is the signature for a custom route handler?
See original GitHub issueLibrary Affected: https://developers.google.com/web/tools/workbox/modules/workbox-routing#matching_and_handling_in_routes
Issue or Feature Request Description: The handler callback method in the docs has the following signature:
const handlerCb = ({url, event, params})
But the handle method in all of the workbox strategies seems to have the following signature;
async handle({ event, request })
I see from the debugger that the object passed to the handle method has the following properties:
{
url: URL,
request: Request,
event: FetchEvent,
params: undefined
}
Could these docs be updated? Or could they point to the API docs for Workbox? (Sorry. I am a java programmer struggling to adjust to this crazy javascript stuff.)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Route handlers - Mirage JS
Route handlers let you define which URLs your Mirage server can handle. The simplest route handler maps a URL ... Each verb method...
Read more >Using a Custom RouteHandler in MVC 2 - Blog
So I was trying to use a custom RouteHandler in ASP. ... the MapRoute() method doesn't have a signature to provide a custom...
Read more >Routing - Laravel - The PHP Framework For Web Artisans
Underscores ( _ ) are also acceptable within route parameter names. Route parameters are injected into route callbacks / controllers based on their...
Read more >Working with routes for WebSocket APIs - Amazon API Gateway
API Gateway calls a custom route after the route selection expression is evaluated against the message if a matching route is found; the...
Read more >HOW TO MAKE YOUR OWN CUSTOM ROUTES IN ...
This is where we would assign a custom route for your application. ... To register events, Umbraco exposes the ApplicationEventHandler base class.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@daffinm note that, in JavaScript, you generally only list the parameters a given method is using—not all the parameters it’s invoked with.
In the case of Workbox strategies, they all only use the
request
andevent
params, but since Workbox’s routing interface accepts handlers that may also useurl
and/orparams
, every invocation of a handler function (which all strategy classeshandle()
method is) from aRouter
object needs to be invoked with all four object params, even if the function doesn’t end up using them.The relevant TypeScript definitions are at https://github.com/GoogleChrome/workbox/blob/3ac095656354157eb4b58c93d3b1e390a5ba34dd/packages/workbox-core/src/types.ts#L36-L56
Ultimately, that’s the intended “source of truth”.
I’m not sure which docs you were looking at, but if anything doesn’t match that (which is unfortunately possible; our docs are generated from JSDocs, not the TypeScript signature) then it’s an issue with the docs that we’ll resolve.
https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-routing#~handlerCallback is the “official” docs—is that what you were looking at? If not, what’s the URL of the page?