mirror of
https://github.com/aljazceru/lspd.git
synced 2025-12-23 08:44:23 +01:00
rename shared package to common
This commit is contained in:
27
common/combined_handler.go
Normal file
27
common/combined_handler.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package common
|
||||
|
||||
import "log"
|
||||
|
||||
type CombinedHandler struct {
|
||||
handlers []InterceptHandler
|
||||
}
|
||||
|
||||
func NewCombinedHandler(handlers ...InterceptHandler) *CombinedHandler {
|
||||
return &CombinedHandler{
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CombinedHandler) Intercept(req InterceptRequest) InterceptResult {
|
||||
for i, handler := range c.handlers {
|
||||
res := handler.Intercept(req)
|
||||
log.Printf("Intercept %+v. Interceptor %d returns %+v", req, i, res)
|
||||
if res.Action != INTERCEPT_RESUME {
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
return InterceptResult{
|
||||
Action: INTERCEPT_RESUME,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user