koa-lite/test/context.js

25 lines
678 B
JavaScript
Raw Permalink Normal View History

2013-08-17 07:15:57 +00:00
var context = require('../lib/context');
var request = require('../lib/request');
var response = require('../lib/response');
2013-08-17 07:15:57 +00:00
var koa = require('..');
exports = module.exports = function(req, res){
2013-08-17 07:15:57 +00:00
req = req || { headers: {} };
res = res || { _headers: {} };
res.setHeader = function(k, v){ res._headers[k.toLowerCase()] = v };
res.removeHeader = function(k, v){ delete res._headers[k.toLowerCase()] };
return koa().createContext(req, res);
2013-08-17 07:15:57 +00:00
}
exports.context = function(req, res){
return exports(req, res);
}
exports.request = function(req, res){
return exports(req, res).request;
}
exports.response = function(req, res){
return exports(req, res).response;
}