Created
December 2, 2016 11:05
-
-
Save ZZR-china/501a15ff6aba5a304f0123fc7e6da133 to your computer and use it in GitHub Desktop.
hapi ext func
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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