本文整理汇总了Golang中bosun/org/cmd/bosun/conf.Notification.RawGet方法的典型用法代码示例。如果您正苦于以下问题:Golang Notification.RawGet方法的具体用法?Golang Notification.RawGet怎么用?Golang Notification.RawGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bosun/org/cmd/bosun/conf.Notification
的用法示例。
在下文中一共展示了Notification.RawGet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: loadNotification
func (c *Conf) loadNotification(s *parse.SectionNode) {
name := s.Name.Text
if _, ok := c.Notifications[name]; ok {
c.errorf("duplicate notification name: %s", name)
}
n := conf.Notification{
Vars: make(map[string]string),
ContentType: "application/x-www-form-urlencoded",
Name: name,
RunOnActions: true,
}
n.Text = s.RawText
n.Locator = newSectionLocator(s)
funcs := ttemplate.FuncMap{
"V": func(v string) string {
return c.Expand(v, n.Vars, false)
},
"json": func(v interface{}) string {
b, err := json.Marshal(v)
if err != nil {
slog.Errorln(err)
}
return string(b)
},
}
c.Notifications[name] = &n
pairs := c.getPairs(s, n.Vars, sNormal)
for _, p := range pairs {
c.at(p.node)
v := p.val
switch k := p.key; k {
case "email":
n.RawEmail = v
email, err := mail.ParseAddressList(n.RawEmail)
if err != nil {
c.error(err)
}
n.Email = email
case "post":
n.RawPost = v
post, err := url.Parse(n.RawPost)
if err != nil {
c.error(err)
}
n.Post = post
case "get":
n.RawGet = v
get, err := url.Parse(n.RawGet)
if err != nil {
c.error(err)
}
n.Get = get
case "print":
n.Print = true
case "contentType":
n.ContentType = v
case "next":
n.NextName = v
next, ok := c.Notifications[n.NextName]
if !ok {
c.errorf("unknown notification %s", n.NextName)
}
n.Next = next
case "timeout":
d, err := opentsdb.ParseDuration(v)
if err != nil {
c.error(err)
}
n.Timeout = time.Duration(d)
case "body":
n.RawBody = v
tmpl := ttemplate.New(name).Funcs(funcs)
_, err := tmpl.Parse(n.RawBody)
if err != nil {
c.error(err)
}
n.Body = tmpl
case "runOnActions":
n.RunOnActions = v == "true"
case "useBody":
n.UseBody = v == "true"
default:
c.errorf("unknown key %s", k)
}
}
c.at(s)
if n.Timeout > 0 && n.Next == nil {
c.errorf("timeout specified without next")
}
}