定义controller,大家喜欢哪种写法?
处理get请求,就直接写一个get方法即可
class MyController extends BaseController {
get () {
var a = this.query.a
return `hello world ${a}`
}
}
模拟servlet,在get方法里传参数,req和res
class MyController extends BaseController {
get (req, res) {
var a = req.query.a
return res.body = `hello world ${a}`
}
}
大家喜欢哪种写法?