boxlang-interceptorslisted
Install: claude install-skill ortus-boxlang/skills
# BoxLang Interceptors
## Overview
BoxLang interceptors provide Aspect-Oriented Programming (AOP) capabilities through
an event-driven announcement system. Interceptors listen to named events and execute
cross-cutting logic — logging, security, caching, validation — without coupling
that logic to business code. Priority controls execution order; async announcements
run in background threads.
## Creating an Interceptor
```boxlang
/**
* interceptors/RequestLogger.bx
*/
class {
function onRequestStart( struct interceptData ) {
request.startTime = getTickCount()
writeLog( text: "Request started: #cgi.script_name#", type: "information" )
}
function onRequestEnd( struct interceptData ) {
var duration = getTickCount() - request.startTime
writeLog( text: "Completed in #duration#ms: #cgi.script_name#", type: "information" )
}
}
```
## Registering Interceptors
### Application.bx (application-scoped)
```boxlang
class {
this.name = "MyApp"
this.interceptors = [
{ class: "interceptors.RequestLogger" },
{ class: "interceptors.SecurityCheck", priority: 1 },
{ class: "interceptors.CacheWarmer", priority: 10 }
]
function onApplicationStart() {
announce( "onApplicationStart", { timestamp: now() } )
}
}
```
### Programmatic Registration (BIF)
```boxlang
// Register at runtime using BoxRegisterInterceptor()
BoxRegisterInterceptor( "interceptors.RequestLogger" )
// With named opti