Skip to content

Commit a6ebe0f

Browse files
authored
feat: app.httpClient alias to app.httpclient (#5304)
let `@Inject() httpClient` work <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new alias for `httpClient` to improve accessibility and usage within the application. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 23866ad commit a6ebe0f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/egg.js

+8
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,14 @@ class EggApplication extends EggCore {
304304
return this[HTTPCLIENT];
305305
}
306306

307+
/**
308+
* @alias httpclient
309+
* @member {HttpClient}
310+
*/
311+
get httpClient() {
312+
return this.httpclient;
313+
}
314+
307315
/**
308316
* All loggers contain logger, coreLogger and customLogger
309317
* @member {Object}

test/lib/core/httpclient.test.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
const assert = require('assert');
1+
const assert = require('node:assert');
42
const mm = require('egg-mock');
53
const urllib = require('urllib');
64
const Httpclient = require('../../../lib/core/httpclient');
@@ -268,6 +266,9 @@ describe('test/lib/core/httpclient.test.js', () => {
268266

269267
it('should app request auto set tracer', async () => {
270268
const httpclient = app.httpclient;
269+
// httpClient alias to httpclient
270+
assert(app.httpClient);
271+
assert.equal(app.httpClient, app.httpclient);
271272

272273
let reqTracer;
273274
let resTracer;

0 commit comments

Comments
 (0)