- javascript/
- Javascript 它没有';如果我在Express Gateway应用程序中记录http响应,则不会显示响应数据
我使用ExpressGateway代理http请求
我制作了一个插件(中间件)来记录http响应
Javascript 它没有';如果我在Express Gateway应用程序中记录http响应,则不会显示响应数据
我使用ExpressGateway代理http请求
我制作了一个插件(中间件)来记录http响应
Javascript 它没有';如果我在Express Gateway应用程序中记录http响应,则不会显示响应数据
我使用ExpressGateway代理http请求
我制作了一个插件(中间件)来记录http响应,javascript,express,Javascript,Express,日志显示ExpressJS响应对象,但我找不到从serviceEndpoints发回的数据
我试图记录“res.body”,但它显示未定义
此环境是docker容器,节点:8.9.4-1
快速网关版本:“^1.9.1”
system.config.json
"plugins": {
"logger": {
"package": "logger"
},
“插件”:{
“记录器”:{
“包”:“记录器”
},
记录器插件:
const stringify = requ
日志显示ExpressJS响应对象,但我找不到从serviceEndpoints发回的数据
我试图记录“res.body”,但它显示未定义
此环境是docker容器,节点:8.9.4-1
快速网关版本:“^1.9.1”
system.config.json
"plugins": {
"logger": {
"package": "logger"
},
“插件”:{
“记录器”:{
“包”:“记录器”
},
记录器插件:
const stringify = require('json-stringify-safe');
module.exports = {
name: 'logger',
init: function (pluginContext) {
pluginContext.registerGatewayRoute(
(gatewayExpressApp) => {
gatewayExpressApp.use((req, res, next) => {
res.on('finish', function () {
console.log('response: %s', stringify(res));
});
next();
});
}
);
}
};
const stringify=require('json-stringify-safe');
module.exports={
名称:“记录器”,
init:函数(pluginContext){
pluginText.registerGatewayRoute(
(gatewayExpressApp)=>{
gatewayExpressApp.use((请求、恢复、下一步)=>{
res.on('finish',function(){
log('response:%s',stringify(res));
});
next();
});
}
);
}
};
res对象显示:
{
"domain": null,
"_events": {
"finish": [null, null, null]
},
"_eventsCount": 5,
"output": [],
"outputEncodings": [],
"outputCallbacks": [],
"outputSize": 0,
"writable": true,
"_last": true,
"upgrading": false,
"chunkedEncoding": false,
"shouldKeepAlive": false,
"useChunkedEncodingByDefault": false,
"sendDate": true,
"_removedConnection": false,
"_removedContLen": false,
"_removedTE": false,
"_contentLength": null,
"_hasBody": true,
"_trailer": "",
"finished": true,
"_headerSent": true,
"socket": null,
"connection": null,
"_header": "HTTP/1.1 200 OK\r\nx-powered-by: Express\r\ntimezone-offset: +0:0\r\ntimezone: UTC\r\ncontent-type: application/json; charset=utf-8\r\ncontent-length: 803\r\netag: W/\"323-lP/wh6xQz1k1vBMgrvl3whFu1vA\"\r\ndate: Thu, 20 Jun 2019 08:00:24 GMT\r\nconnection: close\r\n\r\n",
"_sent100": false,
"_expect_continue": false,
"req": {
...
}
"locals": {},
"statusCode": 200,
"statusMessage": "OK"
}
{
“域”:空,
“_事件”:{
“完成”:[null,null,null]
},
“_eventscont”:5,
“输出”:[],
“输出编码”:[],
“outputCallbacks”:[],
“outputSize”:0,
“可写”:正确,
“_last”:正确,
“升级”:错,
“chunkeden编码”:false,
“shouldKeepAlive”:错误,
“useChunkedEncodingByDefault”:false,
“sendDate”:正确,
“_removedConnection”:false,
“_removedContLen”:错误,
“_removede”:错误,
“_contentLength”:空,
“_hasBody”:没错,
“预告片”:“,
“完成”:对,
“_headerSent”:没错,
“套接字”:空,
“连接”:空,
“\u header”:“HTTP/1.1 200 OK\r\nx由以下驱动:快速\r\ntimezone偏移量:+0:0\r\ntimezone:UTC\r\n内容类型:application/json;charset=utf-8\r\n内容长度:803\r\nTag:W/\”323 lP/wh6xQz1k1vBMgrvl3whFu1vA\“\r\n日期:2019年6月20日星期四08:00:24 GMT\r\n连接:关闭\r\n\r\r\n”,
“_sent100”:错误,
“\u expect\u continue”:false,
“请求”:{
...
}
“当地人”:{},
“状态代码”:200,
“状态消息”:“确定”
}
我想看看这个
{
"status": "success",
"data": {
"rows": [],
"rowLength": 0,
"pageState": null
},
"error": ""
}
{
“状态”:“成功”,
“数据”:{
“行”:[],
“行长度”:0,
“页面状态”:空
},
“错误”:”
}