Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
10a5885a
Commit
10a5885a
authored
Jul 27, 2020
by
v_vjyjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
3c6b84d5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
26 deletions
+34
-26
center-manage/app/config/routes/api.js
+34
-26
No files found.
center-manage/app/config/routes/api.js
View file @
10a5885a
var
url
=
require
(
"url"
);
var
System
=
require
(
"../../base/system"
);
const
chnelapi
=
System
.
getObject
(
"api.common.channels"
)
const
chnelapi
=
System
.
getObject
(
"api.common.channels"
)
var
channelCache
=
{}
module
.
exports
=
function
(
app
)
{
app
.
all
(
"*"
,
async
function
(
req
,
res
,
next
){
try
{
let
channel
=
await
chnelapi
.
getChannels
(
req
.
headers
[
"x-forwarded-host"
])
if
(
!
channel
){
app
.
all
(
"*"
,
async
function
(
req
,
res
,
next
)
{
try
{
let
channel
=
null
let
hostaddr
=
req
.
headers
[
"x-forwarded-host"
]
if
(
!
channelCache
[
hostaddr
])
{
channel
=
await
chnelapi
.
getChannels
(
req
.
headers
[
"x-forwarded-host"
])
channelCache
[
hostaddr
]
=
channel
}
else
{
channel
=
channelCache
[
hostaddr
]
}
if
(
!
channel
)
{
next
()
}
else
{
let
rtn
=
await
chnelapi
.
channelHandle
(
channel
,
req
.
path
+
"/"
+
req
.
body
.
actionType
,
req
.
body
)
if
(
rtn
!=
null
)
{
}
else
{
let
rtn
=
await
chnelapi
.
channelHandle
(
channel
,
req
.
path
+
"/"
+
req
.
body
.
actionType
,
req
.
body
)
if
(
rtn
!=
null
)
{
res
.
end
(
JSON
.
stringify
(
rtn
));
}
else
{
res
.
end
(
JSON
.
stringify
({
status
:
-
1
,
message
:
"fail"
}));
}
else
{
res
.
end
(
JSON
.
stringify
({
status
:
-
1
,
message
:
"fail"
}));
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
)
res
.
end
(
JSON
.
stringify
({
status
:
-
1
,
message
:
e
}));
res
.
end
(
JSON
.
stringify
({
status
:
-
1
,
message
:
e
}));
}
})
app
.
get
(
'/api/:gname/:qname/:method'
,
function
(
req
,
res
)
{
// var classPath = req.params["qname"];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
classPath
=
gname
+
"."
+
classPath
;
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
System
.
get_client_ip
(
req
);
req
.
clientIp
=
tClientIp
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
uagent
=
req
.
headers
[
"user-agent"
];
// req.classname=classPath;
var
params
=
[];
params
.
push
(
gname
);
params
.
push
(
methodName
);
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
var
p
=
null
;
var
invokeObj
=
System
.
getObject
(
"api."
+
classPath
);
if
(
invokeObj
[
"doexec"
])
{
...
...
@@ -47,22 +55,22 @@ module.exports = function (app) {
});
app
.
post
(
'/api/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
console
.
log
(
"===================="
);
console
.
log
(
classPath
);
var
tClientIp
=
System
.
get_client_ip
(
req
);
req
.
clientIp
=
tClientIp
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
uagent
=
req
.
headers
[
"user-agent"
];
// req.classname=classPath;
params
.
push
(
gname
);
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
var
p
=
null
;
var
invokeObj
=
System
.
getObject
(
"api."
+
classPath
);
if
(
invokeObj
[
"doexec"
])
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment