GoogleChromeLabs / sw-toolbox

[Deprecated] A collection of service worker tools for offlining runtime requests
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
Apache License 2.0
3.62k stars 331 forks source link

Support configuring a custom function with the request object as an input param for URL pattern #261

Closed liuruoran88 closed 7 years ago

liuruoran88 commented 7 years ago

sw-toolbox has two options, Express-style Routes and Regular Expression Routes, for configuring the routes, but it's not flexible enough for users. If it can support configuring a custom function with the request object as an input param for url pattern,users can do more processing according to the request object. In order to meet this need, I have changed two files, lib/router.js and lib/route.js, and added some test cases in the test folder. These changes will not affect the original Routes config.Your prompt attention to this matter will be appreciated.

An example of using Function Expression routing include:

toolbox.router.get(
function(request){
  // users can get request object, do some processing accroding to the request object and return a boolean value
  if (request && reqest.headers && request.headers.referer) {
     return true;
  } 
}, apiHandler);
googlebot commented 7 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


liuruoran88 commented 7 years ago

I signed it!

googlebot commented 7 years ago

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

liuruoran88 commented 7 years ago

ok, I have committed another new PR, please check again, thank you!