@@ -6,19 +6,19 @@ import { Headers, CompletedRequest, Method, MockedEndpoint, Trailers } from "../
6
6
import type { RequestRuleData } from "./request-rule" ;
7
7
8
8
import {
9
- SimpleHandlerDefinition ,
10
- PassThroughHandlerDefinition ,
11
- CallbackHandlerDefinition ,
9
+ SimpleStepDefinition ,
10
+ PassThroughStepDefinition ,
11
+ CallbackStepDefinition ,
12
12
CallbackResponseResult ,
13
- StreamHandlerDefinition ,
14
- CloseConnectionHandlerDefinition ,
15
- TimeoutHandlerDefinition ,
16
- PassThroughHandlerOptions ,
17
- FileHandlerDefinition ,
18
- JsonRpcResponseHandlerDefinition ,
19
- ResetConnectionHandlerDefinition ,
13
+ StreamStepDefinition ,
14
+ CloseConnectionStepDefinition ,
15
+ TimeoutStepDefinition ,
16
+ PassThroughStepOptions ,
17
+ FileStepDefinition ,
18
+ JsonRpcResponseStepDefinition ,
19
+ ResetConnectionStepDefinition ,
20
20
CallbackResponseMessageResult
21
- } from "./request-handler -definitions" ;
21
+ } from "./request-step -definitions" ;
22
22
import { byteLength } from "../../util/util" ;
23
23
import { BaseRuleBuilder } from "../base-rule-builder" ;
24
24
import { MethodMatcher , RegexPathMatcher , SimplePathMatcher , WildcardMatcher } from "../matchers" ;
@@ -141,13 +141,13 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
141
141
142
142
const rule : RequestRuleData = {
143
143
...this . buildBaseRuleData ( ) ,
144
- handler : new SimpleHandlerDefinition (
144
+ steps : [ new SimpleStepDefinition (
145
145
status ,
146
146
statusMessage ,
147
147
data ,
148
148
headers ,
149
149
trailers
150
- )
150
+ ) ]
151
151
} ;
152
152
153
153
return this . addRule ( rule ) ;
@@ -184,7 +184,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
184
184
185
185
const rule : RequestRuleData = {
186
186
...this . buildBaseRuleData ( ) ,
187
- handler : new SimpleHandlerDefinition ( status , undefined , jsonData , headers )
187
+ steps : [ new SimpleStepDefinition ( status , undefined , jsonData , headers ) ]
188
188
} ;
189
189
190
190
return this . addRule ( rule ) ;
@@ -218,7 +218,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
218
218
) : Promise < MockedEndpoint > {
219
219
const rule : RequestRuleData = {
220
220
...this . buildBaseRuleData ( ) ,
221
- handler : new CallbackHandlerDefinition ( callback )
221
+ steps : [ new CallbackStepDefinition ( callback ) ]
222
222
}
223
223
224
224
return this . addRule ( rule ) ;
@@ -247,7 +247,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
247
247
thenStream ( status : number , stream : Readable , headers ?: Headers ) : Promise < MockedEndpoint > {
248
248
const rule : RequestRuleData = {
249
249
...this . buildBaseRuleData ( ) ,
250
- handler : new StreamHandlerDefinition ( status , stream , headers )
250
+ steps : [ new StreamStepDefinition ( status , stream , headers ) ]
251
251
}
252
252
253
253
return this . addRule ( rule ) ;
@@ -296,7 +296,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
296
296
297
297
const rule : RequestRuleData = {
298
298
...this . buildBaseRuleData ( ) ,
299
- handler : new FileHandlerDefinition ( status , statusMessage , path , headers )
299
+ steps : [ new FileStepDefinition ( status , statusMessage , path , headers ) ]
300
300
} ;
301
301
302
302
return this . addRule ( rule ) ;
@@ -308,7 +308,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
308
308
* an error.
309
309
*
310
310
* This method takes options to configure how the request is passed
311
- * through. See {@link PassThroughHandlerOptions } for the full details
311
+ * through. See {@link PassThroughStepOptions } for the full details
312
312
* of the options available.
313
313
*
314
314
* Calling this method registers the rule with the server, so it
@@ -321,10 +321,10 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
321
321
*
322
322
* @category Responses
323
323
*/
324
- thenPassThrough ( options ?: PassThroughHandlerOptions ) : Promise < MockedEndpoint > {
324
+ thenPassThrough ( options ?: PassThroughStepOptions ) : Promise < MockedEndpoint > {
325
325
const rule : RequestRuleData = {
326
326
...this . buildBaseRuleData ( ) ,
327
- handler : new PassThroughHandlerDefinition ( options )
327
+ steps : [ new PassThroughStepDefinition ( options ) ]
328
328
} ;
329
329
330
330
return this . addRule ( rule ) ;
@@ -341,7 +341,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
341
341
* of the original request URL will be used instead.
342
342
*
343
343
* This method takes options to configure how the request is passed
344
- * through. See {@link PassThroughHandlerOptions } for the full details
344
+ * through. See {@link PassThroughStepOptions } for the full details
345
345
* of the options available.
346
346
*
347
347
* Calling this method registers the rule with the server, so it
@@ -356,19 +356,19 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
356
356
*/
357
357
async thenForwardTo (
358
358
forwardToLocation : string ,
359
- options : Omit < PassThroughHandlerOptions , 'forwarding' > & {
360
- forwarding ?: Omit < PassThroughHandlerOptions [ 'forwarding' ] , 'targetHost' >
359
+ options : Omit < PassThroughStepOptions , 'forwarding' > & {
360
+ forwarding ?: Omit < PassThroughStepOptions [ 'forwarding' ] , 'targetHost' >
361
361
} = { }
362
362
) : Promise < MockedEndpoint > {
363
363
const rule : RequestRuleData = {
364
364
...this . buildBaseRuleData ( ) ,
365
- handler : new PassThroughHandlerDefinition ( {
365
+ steps : [ new PassThroughStepDefinition ( {
366
366
...options ,
367
367
forwarding : {
368
368
...options . forwarding ,
369
369
targetHost : forwardToLocation
370
370
}
371
- } )
371
+ } ) ]
372
372
} ;
373
373
374
374
return this . addRule ( rule ) ;
@@ -391,7 +391,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
391
391
thenCloseConnection ( ) : Promise < MockedEndpoint > {
392
392
const rule : RequestRuleData = {
393
393
...this . buildBaseRuleData ( ) ,
394
- handler : new CloseConnectionHandlerDefinition ( )
394
+ steps : [ new CloseConnectionStepDefinition ( ) ]
395
395
} ;
396
396
397
397
return this . addRule ( rule ) ;
@@ -418,7 +418,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
418
418
thenResetConnection ( ) : Promise < MockedEndpoint > {
419
419
const rule : RequestRuleData = {
420
420
...this . buildBaseRuleData ( ) ,
421
- handler : new ResetConnectionHandlerDefinition ( )
421
+ steps : [ new ResetConnectionStepDefinition ( ) ]
422
422
} ;
423
423
424
424
return this . addRule ( rule ) ;
@@ -441,7 +441,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
441
441
thenTimeout ( ) : Promise < MockedEndpoint > {
442
442
const rule : RequestRuleData = {
443
443
...this . buildBaseRuleData ( ) ,
444
- handler : new TimeoutHandlerDefinition ( )
444
+ steps : [ new TimeoutStepDefinition ( ) ]
445
445
} ;
446
446
447
447
return this . addRule ( rule ) ;
@@ -457,7 +457,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
457
457
thenSendJsonRpcResult ( result : any ) {
458
458
const rule = {
459
459
...this . buildBaseRuleData ( ) ,
460
- handler : new JsonRpcResponseHandlerDefinition ( { result } )
460
+ steps : [ new JsonRpcResponseStepDefinition ( { result } ) ]
461
461
} ;
462
462
463
463
return this . addRule ( rule ) ;
@@ -473,7 +473,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
473
473
thenSendJsonRpcError ( error : any ) {
474
474
const rule = {
475
475
...this . buildBaseRuleData ( ) ,
476
- handler : new JsonRpcResponseHandlerDefinition ( { error } )
476
+ steps : [ new JsonRpcResponseStepDefinition ( { error } ) ]
477
477
} ;
478
478
479
479
return this . addRule ( rule ) ;
0 commit comments