Commit 86463fe2 authored by 李尚科's avatar 李尚科

add helper getClientIp

parent 8494c664
Pipeline #6663 passed with stage
in 10 seconds
......@@ -245,6 +245,16 @@ module.exports = {
return array;
},
// 获取客户端IP
getClientIP() {
const { ctx } = this;
const ips = ctx.request.header['x-forwarded-for'];
const ipList = ips ? ips.split(',') : [ '' ];
const ip = ipList[0];
return ip;
},
JsonParse(jsonStr) {
try {
return JSON.parse(jsonStr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment