Commit 1d276621 authored by 肖人杰's avatar 肖人杰

'调整判断逻辑'

parent e6b7652b
......@@ -28,18 +28,6 @@ class ApiError extends Error {
}
}
const cmdArgs = process.argv
let isLocal = false
cmdArgs.forEach((arg) => {
if(arg == 'local'){
isLocal = true
}
})
const services = {
"pay": "http://svc-api-yitong-com-pay-v1/"
}
/**
......@@ -59,16 +47,14 @@ const http = axios.create({
// https://github.com/fapspirit/axios-opentracing
http.interceptors.request.use(function (config) {
if(!isLocal) {
let regExp = new RegExp(/(http|https):\/\/api.(dev.|test.|)yitong.com\/[\D]*\//)
if(regExp.test(config.url)){
let service = config.url.match(regExp)[0].split('/')[3]
let k8sService = services[service]
if(k8sService) {
config.url = config.url.replace(regExp, k8sService)
if(global.serviceMap) {
let paths = config.url.split("/")
if(paths.length >= 4){
let pathKey = paths[0] + "//" + paths[2] + "/" + paths[3] + "/"
if(global.serviceMap[pathKey]) {
config.url = config.url.replace(pathKey, global.serviceMap[pathKey])
}
}
}
if (config.context && config.context.span) {
let tracer = opentracing.globalTracer();
......
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