File tree 3 files changed +11
-7
lines changed
test/fixtures/apps/app-ts/app/controller
3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -36,3 +36,4 @@ site/dist
36
36
.umi-production
37
37
.vercel
38
38
package-lock.json
39
+ .tshy *
Original file line number Diff line number Diff line change @@ -19,9 +19,9 @@ import {
19
19
HttpClientResponse as HttpClientResponseOld ,
20
20
} from 'urllib' ;
21
21
import {
22
- RequestURL as HttpClientRequestURL ,
23
- RequestOptions as HttpClientRequestOptions ,
24
- HttpClientResponse ,
22
+ RequestURL ,
23
+ RequestOptions ,
24
+ HttpClientResponse as HttpClientResponseNext ,
25
25
} from 'urllib-next' ;
26
26
import {
27
27
EggCoreBase ,
@@ -60,7 +60,9 @@ declare module 'egg' {
60
60
// return await app.httpclient.request(url, options);
61
61
// }
62
62
// ```
63
- export { HttpClientRequestURL , HttpClientRequestOptions , HttpClientResponse } ;
63
+ export type HttpClientRequestURL = RequestURL ;
64
+ export type HttpClientRequestOptions = RequestOptions ;
65
+ export type HttpClientResponse < T = any > = HttpClientResponseNext < T > ;
64
66
// Compatible with both urllib@2 and urllib@3 RequestOptions to request
65
67
export interface EggHttpClient extends EventEmitter {
66
68
request < T = any > ( url : HttpClientRequestURL ) : Promise < HttpClientResponseOld < T > | HttpClientResponse < T > > ;
Original file line number Diff line number Diff line change 6
6
EggLogger ,
7
7
EggHttpClient ,
8
8
EggContextHttpClient ,
9
+ HttpClientRequestURL ,
10
+ HttpClientRequestOptions as RequestOptionsNext ,
9
11
} from 'egg' ;
10
- import { RequestOptions as RequestOptionsNext } from 'urllib-next' ;
11
12
import { RequestOptions2 , RequestOptions } from 'urllib' ;
12
13
13
14
// add user controller and service
@@ -59,8 +60,8 @@ export default class FooController extends Controller {
59
60
}
60
61
}
61
62
62
- async requestWithHttpclientNext ( request : RequestOptionsNext ) {
63
- let result = await this . app . curl ( 'url' , request ) ;
63
+ async requestWithHttpclientNext ( request : RequestOptionsNext , url ?: HttpClientRequestURL ) {
64
+ let result = await this . app . curl ( url ?? 'url' , request ) ;
64
65
result = await this . ctx . curl ( 'url' , request ) ;
65
66
result = await this . app . httpclient . curl ( 'url' , request ) ;
66
67
result = await this . app . httpclient . request ( 'url' , request ) ;
You can’t perform that action at this time.
0 commit comments