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
Raw Normal View History

2017-12-16 23:20:46 +01:00
package extension
import (
"encoding/xml"
2018-02-07 15:34:18 +01:00
"dev.sum7.eu/genofire/yaja/server/utils"
2017-12-16 23:20:46 +01:00
)
type Extensions []Extension
2017-12-16 23:20:46 +01:00
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)
}
2017-12-16 23:20:46 +01:00
}