Skip to content

Instantly share code, notes, and snippets.

@jsloyer
Created September 23, 2015 17:58
Show Gist options
  • Save jsloyer/9961c59eeb2cb876443b to your computer and use it in GitHub Desktop.
Save jsloyer/9961c59eeb2cb876443b to your computer and use it in GitHub Desktop.
function authenticate() {
return function(request, response, next) {
if (request.headers["secret"] !== "supersecretkey") {
response.send("Must authenticate");
return next();
}
};
}
app.get("/secured-api", authenticate(),function (request, response) {
//do stuff
response.send("your response");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment