mirror of
https://github.com/eggjs/egg.git
synced 2024-12-04 07:14:30 +00:00
22 lines
475 B
JavaScript
22 lines
475 B
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
|
|
module.exports = app => {
|
|
class CustomHttpClient extends app.HttpClient {
|
|
request(url, opt) {
|
|
return new Promise(resolve => {
|
|
assert(/^http/.test(url), 'url should start with http, but got ' + url);
|
|
resolve();
|
|
}).then(() => {
|
|
return super.request(url, opt);
|
|
});
|
|
}
|
|
|
|
curl(url, opt) {
|
|
return this.request(url, opt);
|
|
}
|
|
}
|
|
app.HttpClient = CustomHttpClient;
|
|
};
|