egg 3.11.1 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,15 +3,17 @@
3
3
  const path = require('path');
4
4
 
5
5
  module.exports = options => {
6
- return function siteFile(ctx, next) {
6
+ return async function siteFile(ctx, next) {
7
7
  if (ctx.method !== 'HEAD' && ctx.method !== 'GET') return next();
8
8
  /* istanbul ignore if */
9
9
  if (ctx.path[0] !== '/') return next();
10
10
 
11
- const content = options[ctx.path];
11
+ let content = options[ctx.path];
12
12
  if (!content) return next();
13
13
 
14
- // '/favicon.ico': 'https://eggjs.org/favicon.ico',
14
+ // '/favicon.ico': 'https://eggjs.org/favicon.ico' or '/favicon.ico': async (ctx) => 'https://eggjs.org/favicon.ico'
15
+ // content is function
16
+ if (typeof content === 'function') content = await content(ctx);
15
17
  // content is url
16
18
  if (typeof content === 'string') return ctx.redirect(content);
17
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "3.11.1",
3
+ "version": "3.12.0",
4
4
  "publishConfig": {
5
5
  "tag": "latest"
6
6
  },