import MiddlewareInterface from '../interface/MiddlewareInterface' ; export default class MiddlewareHandle implements MiddlewareInterface { protected args : any [ ] = [ ] ; protected _isOptional : boolean = false ; protected _isInTerminal : boolean = false ; public constructor ( ) { let handle = this . handle ; this . handle = function ( next , ... arg ) { let args = [ next ] ; args . push . apply ( args , this . args ) ; args . push . apply ( args , arg ) ; handle . apply ( this , args ) ; } ; } public clearArgs ( ) { this . args = [ ] ; return this ; } public handle ( ... args ) { } public isOptional ( ) { return this . _isOptional ; } public isTerminal ( ) { return this . _isInTerminal ; } public optional ( optional = true ) { this . _isOptional = optional ; return this ; } public setArgs ( args ) { this . args = args ; return this ; } public terminal ( terminal = true ) { this . _isInTerminal = terminal ; return this ; } }