mm_os
Version:
这是超级美眉服务端框架,用于快速构建应用程序。
21 lines • 503 B
JavaScript
/**
* web日志
* @param {Object} server 服务
* @param {Object} config 配置参数
*/
module.exports = function(server, config) {
/* 跨域限制(web防火墙) */
server.use(async (ctx, next) => {
var url = ctx.path + ctx.querystring;
var body = "";
if (ctx.request.body) {
body = JSON.stringify(ctx.request.body);
if (body.length > 1024) {
body = body.substring(0, 1024) + "..."
}
}
$.log.http(`${ctx.method} ${url} ${body}`);
await next();
});
return server;
};