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.
38 lines
960 B
38 lines
960 B
/**
|
|
* 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;
|
|
}
|
|
};
|
|
|