1
This commit is contained in:
commit
85dac9425a
@ -4,7 +4,7 @@ const utils = require('j7/utils');
|
||||
const http = require('j7/http');
|
||||
const serviceFactory = require('../services/factory');
|
||||
|
||||
async function get(session) {
|
||||
async function internalGet(session) {
|
||||
const seqId = session.request('seq_id');
|
||||
const targetUrl = session.request('target_url');
|
||||
const cbUrl = session.request('cb_url');
|
||||
@ -28,6 +28,43 @@ async function get(session) {
|
||||
await http.get(cbUrl, rspJson);
|
||||
});
|
||||
session.rspOk();
|
||||
}
|
||||
|
||||
async function internalPost(session, postData) {
|
||||
const seqId = session.request('seq_id');
|
||||
const targetUrl = session.request('target_url');
|
||||
const cbUrl = session.request('cb_url');
|
||||
const reqJson = session.requestToJson();
|
||||
new Promise(async (resolve) => {
|
||||
const params = utils.jsonDecode(session.request('params'));
|
||||
delete params['__POST'];
|
||||
const {err, data} = await http.post(targetUrl, params, postData);
|
||||
const rspJson = {
|
||||
'errcode': 0,
|
||||
'errmsg': '',
|
||||
'seq_id': seqId,
|
||||
'req_json': reqJson,
|
||||
'data': data
|
||||
};
|
||||
if (err) {
|
||||
rspJson['errcode'] = 1;
|
||||
rspJson['errmsg'] = '' + err;
|
||||
}
|
||||
console.log('data', data);
|
||||
console.log('rspJson:' + utils.jsonEncode(rspJson));
|
||||
await http.get(cbUrl, rspJson);
|
||||
});
|
||||
session.rspOk();
|
||||
}
|
||||
|
||||
async function get(session) {
|
||||
const params = utils.jsonDecode(session.request('params'));
|
||||
const postData = utils.getVal(params, '__POST', '');
|
||||
if (postData) {
|
||||
await internalPost(session, postData);
|
||||
} else {
|
||||
await internalGet(session);
|
||||
}
|
||||
};
|
||||
|
||||
async function post(session) {
|
||||
|
2
third_party/j7
vendored
2
third_party/j7
vendored
@ -1 +1 @@
|
||||
Subproject commit 59b3ef222d3468ccb7096a801a43da7d9b158412
|
||||
Subproject commit f81baf8c264c00395b4dd27f900df6ffedceac08
|
Loading…
x
Reference in New Issue
Block a user