Created
April 19, 2016 22:37
-
-
Save christopheranderson/da155d860c5a1c4671bbb1f9fceabad4 to your computer and use it in GitHub Desktop.
Simple verb routing for Azure Functions HTTP Trigger
This file contains hidden or 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
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