Skip to content

Instantly share code, notes, and snippets.

@theburningmonk
Created August 28, 2017 13:50
Show Gist options
  • Save theburningmonk/d8133aece27aa67e0d897d68297ec1f9 to your computer and use it in GitHub Desktop.
Save theburningmonk/d8133aece27aa67e0d897d68297ec1f9 to your computer and use it in GitHub Desktop.
'use strict';
const co = require('co');
const log = require('../lib/log');
const http = require('../lib/http');
const apiHandler = require('../lib/apiHandler');
const reqContext = require('../lib/requestContext');
module.exports.handler = apiHandler(
co.wrap(function* (event, context) {
reqContext.set("character-a", "tywin");
log.debug("this is a DEBUG log");
log.info("this is an INFO log");
log.warn("this is a WARNING log");
log.error("this is an ERROR log");
// do a bunch of stuff, like calling another HTTP endpoint
let host = event.headers.Host;
reqContext.set("host", host);
let uri = `https://${host}/dev/api-b`;
log.info("calling api-b", { uri });
let reply = yield http({
uri : uri,
method : 'GET'
});
...
return {
message: 'A Lannister always pays his debts'
};
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment