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.
33 lines
699 B
33 lines
699 B
/**
|
|
* Created by PengLing on 2017/7/3.
|
|
*/
|
|
'use strict'
|
|
|
|
const request = require('superagent');
|
|
|
|
class AxyReq {
|
|
constructor(root) {
|
|
this.apiRoot = root
|
|
}
|
|
|
|
get(url) {
|
|
return request.get(`${this.apiRoot}${url}`);
|
|
}
|
|
|
|
post(url, data) {
|
|
return request.post(`${this.apiRoot}${url}`).set('Content-Type', 'application/json').send(data)
|
|
}
|
|
|
|
put(url, data) {
|
|
return request.put(`${this.apiRoot}${url}`).set('Content-Type', 'application/json').send(data)
|
|
}
|
|
|
|
delete(url) {
|
|
return request.del(`${this.apiRoot}${url}`)
|
|
}
|
|
}
|
|
|
|
module.exports = function (app, opts) {
|
|
const req = new AxyReq(opts.waterUrl)
|
|
app.fs.waterReq = req
|
|
}
|