sum7
/
yaja
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
yaja/server/extension/main.go

39 lines
696 B
Go

package extension
import (
"encoding/xml"
"dev.sum7.eu/genofire/yaja/server/utils"
)
type Extensions []Extension
type Extension interface {
Process(*xml.StartElement, *utils.Client) bool
Spaces() []string
}
func (ex Extensions) Spaces() (result []string) {
for _, extension := range ex {
result = append(result, extension.Spaces()...)
}
return result
}
func (ex Extensions) Process(element *xml.StartElement, client *utils.Client) {
log := client.Log.WithField("extension", "all")
// run every extensions
count := 0
for _, extension := range ex {
if extension.Process(element, client) {
count++
}
}
// not extensions found
if count != 1 {
log.Debug(element)
}
}