Closed zj8487 closed 9 years ago
@fantasyni i think a todo example based on koa is helpful!
I will test it soon ~
this style will work.
http.post('/xx/auth/',
testMiddleware.auth(),
);
"use strict";
var TestMiddleware = function() {
this.$id = "testMiddleware";
}
TestMiddleware.prototype.auth = function () {
return function* (next) {
this.checkBody('password', 'Invalid password').notEmpty();
if (this.errors){
this.body = this.errors;
return;
}
}
};
module.exports = TestMiddleware;
hi, i plan to migrate to koa from express.
i write a middleware with bearcat as follow:
but
this.body
is not defined. i print the this in the auth function. it says that this is TestMiddleware object.