You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
960 B
39 lines
960 B
1 year ago
|
/**
|
||
|
* Created by PengLing on 2017/7/3.
|
||
|
*/
|
||
|
'use strict';
|
||
|
|
||
|
const request = require('superagent');
|
||
|
|
||
|
module.exports = {
|
||
|
entry: (app, router, opts) => {
|
||
|
const apiRoot = `${opts.host}${opts.match}`;
|
||
|
const req = {
|
||
|
get: (url) => {
|
||
|
return request.get(`${apiRoot}${url}`);
|
||
|
},
|
||
|
|
||
|
post: (url, data) => {
|
||
|
return request
|
||
|
.post(`${apiRoot}${url}`)
|
||
|
.set('Content-Type', 'application/json')
|
||
|
.send(data);
|
||
|
},
|
||
|
|
||
|
put: (url, data) => {
|
||
|
return request
|
||
|
.put(`${apiRoot}${url}`)
|
||
|
.set('Content-Type', 'application/json')
|
||
|
.send(data);
|
||
|
},
|
||
|
|
||
|
delete: (url) => {
|
||
|
return request.del(`${apiRoot}${url}`);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
app.iota = app.iota || {};
|
||
|
app.iota.request = req;
|
||
|
}
|
||
|
};
|