Skip to content

Instantly share code, notes, and snippets.

@theburningmonk
Last active July 5, 2019 13:01
Show Gist options
  • Save theburningmonk/c08e5762a4c6eb757b475d237e1cf4c9 to your computer and use it in GitHub Desktop.
Save theburningmonk/c08e5762a4c6eb757b475d237e1cf4c9 to your computer and use it in GitHub Desktop.
module.exports.handler = co.wrap(function* (event, context, callback) {
let players = lib.genPlayers();
let accept = event.headers.Accept || "application/json";
switch (accept) {
case "application/x-protobuf":
let response = yield protoResponse(players, "functions/player.proto", "protodemo.Players");
callback(null, response);
break;
case "application/json":
callback(null, jsonResponse(players));
break;
default:
callback(null, NotAcceptableResponse);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment