Skip to content

Instantly share code, notes, and snippets.

@christopheranderson
Created April 19, 2016 22:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save christopheranderson/da155d860c5a1c4671bbb1f9fceabad4 to your computer and use it in GitHub Desktop.
Simple verb routing for Azure Functions HTTP Trigger
module.exports = function(context, req) {
var method = req.method.toLowerCase();
context.log(JSON.stringify(req, null, " "));
if(methods[method]){
methods[method](context, req);
} else {
context.res = {
status: 404,
body: "No route found for VERB: " + req.method
}
context.done();
}
};
var methods = {
get: function(context, req){
context.res = {
body: "This was a GET request"
};
context.done();
},
post: function(context, req){
context.res = {
body: "This was a POST request"
};
context.done();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment