- customisable time format
- custom messages - configure threshold count instead of uptime %
This commit is contained in:
17
template.go
17
template.go
@@ -1,6 +1,11 @@
|
||||
package cachet
|
||||
|
||||
import "text/template"
|
||||
import (
|
||||
"bytes"
|
||||
"text/template"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
type MessageTemplate struct {
|
||||
Subject string `json:"subject"`
|
||||
@@ -33,6 +38,16 @@ func (t *MessageTemplate) Compile() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (t *MessageTemplate) Exec(data interface{}) (string, string) {
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
logrus.Warnf("%#v", t.subjectTpl)
|
||||
t.subjectTpl.Execute(buf, data)
|
||||
subject := buf.String()
|
||||
|
||||
return subject, ""
|
||||
}
|
||||
|
||||
func compileTemplate(text string) (*template.Template, error) {
|
||||
return template.New("").Parse(text)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user