Skip to content

Instantly share code, notes, and snippets.

@ZZR-china
Created December 2, 2016 11:05
Show Gist options
  • Save ZZR-china/501a15ff6aba5a304f0123fc7e6da133 to your computer and use it in GitHub Desktop.
Save ZZR-china/501a15ff6aba5a304f0123fc7e6da133 to your computer and use it in GitHub Desktop.
hapi ext func
/**
* with hapi, you should catch request in his way
* I am going to build a web Permission System
* use hapi's ext func , I can catch req before it get in
* route
*/
server.ext('onRequest', function(request, reply) {
const JWT = require('jsonwebtoken');
const token = request.headers.authorization;
const path = request.path;
const decoded = JWT.verify(token, secret);
console.log("decoded", decoded);
return reply.continue();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment