Egg: 老夫有一小建议,可否把全部代码里的ctx 改成context

Created on 3 Dec 2020  ·  3Comments  ·  Source: eggjs/egg

ctx实在不够清晰, 老夫悟性不佳,悟了半天才悟出来是context

Most helpful comment

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello, World!\n');
});

Node 官方这个,也没备注个 req === request 啥的。

如果你熟悉 Koa ,ctx 应该很脸熟了。改这个没啥收益,先这样吧。

All 3 comments

代码里的缩写很多,都改成全拼没有开源项目会这么干吧

代码里的缩写很多,都改成全拼没有开源项目会这么干吧

兄台所言甚是 , 在文档中提一句也好

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello, World!\n');
});

Node 官方这个,也没备注个 req === request 啥的。

如果你熟悉 Koa ,ctx 应该很脸熟了。改这个没啥收益,先这样吧。

Was this page helpful?
0 / 5 - 0 ratings