Skip to content

Instantly share code, notes, and snippets.

@kudos
Created March 24, 2015 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kudos/610266fd195b73932dd9 to your computer and use it in GitHub Desktop.
Save kudos/610266fd195b73932dd9 to your computer and use it in GitHub Desktop.
Wrapping Fetchr middleware to make it consumable with Koa
"use strict";
const koa = require('koa');
const bodyparser = require('koa-bodyparser');
const koaFetchr = require('koa-fetchr');
const fetchr = require('fetchr');
const app = koa();
app.use(bodyparser());
app.use(koaFetchr(fetchr));
app.listen(3000);
"use strict";
module.exports = function (fetchr) {
return function* (next) {
const mw = fetchr.middleware();
this.req.path = this.req.url;
mw(this.req, this.res);
return yield* next;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment