Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions models/HyperRequest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ component accessors="true" {
// This is overwritten by the HyperBuilder if WireBox exists.
variables.interceptorService = {
"processState" : function() {
},
"announce" : function() {
}
};

Expand Down Expand Up @@ -1096,15 +1098,15 @@ component accessors="true" {
for ( var callback in variables.requestCallbacks ) {
callback( this );
}
variables.interceptorService.processState( "onHyperRequest", { "request" : this } );
announceInterception( "onHyperRequest", { "request" : this } );

try {
var res = shouldFake() ? generateFakeRequest() : variables.httpClient.send( this );

for ( var callback in variables.responseCallbacks ) {
callback( res );
}
variables.interceptorService.processState(
announceInterception(
"onHyperResponse",
{
"response" : res,
Expand Down Expand Up @@ -1166,7 +1168,7 @@ component accessors="true" {
for ( var callback in variables.requestCallbacks ) {
callback( this );
}
variables.interceptorService.processState( "onHyperRequest", { "request" : this } );
announceInterception( "onHyperRequest", { "request" : this } );

return httpClient.debug( this );
}
Expand Down Expand Up @@ -1572,4 +1574,19 @@ component accessors="true" {
return application.hyperVersion;
}

/**
* Announces interception events using the appropriate method for backward compatibility.
* Uses announce() for ColdBox 8+ and falls back to processState() for older versions.
*
* @interceptionPoint The name of the interception point
* @data The data to pass to the interceptors
*/
private void function announceInterception( required string interceptionPoint, struct data = {} ) {
if ( structKeyExists( variables.interceptorService, "announce" ) ) {
variables.interceptorService.announce( arguments.interceptionPoint, arguments.data );
} else {
variables.interceptorService.processState( arguments.interceptionPoint, arguments.data );
}
}

}
Loading