本文整理汇总了Golang中github.com/danryan/hal.Response类的典型用法代码示例。如果您正苦于以下问题:Golang Response类的具体用法?Golang Response怎么用?Golang Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Response类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Reply
// Reply sends a direct response
func (a *adapter) Reply(res *hal.Response, strings ...string) error {
newStrings := make([]string, len(strings))
for _, str := range strings {
newStrings = append(newStrings, fmt.Sprintf("%s: %s", res.UserName(), str))
}
a.Send(res, newStrings...)
return nil
}
示例2: Reply
// Reply sends a direct response
func (a *adapter) Reply(res *hal.Response, strings ...string) error {
newStrings := make([]string, len(strings))
for _, str := range strings {
newStrings = append(newStrings, res.UserID()+`: `+str)
}
a.Send(res, newStrings...)
return nil
}
示例3: Reply
// Reply sends a direct response
func (a *adapter) Reply(res *hal.Response, strings ...string) error {
for _, str := range strings {
s := res.UserName() + `: ` + str
err := a.writeString(s)
if err != nil {
log.Println("error: ", err)
return err
}
}
return nil
}
示例4: ExampleHandler_hear
func ExampleHandler_hear() {
res := hal.Response{
Match: []string{},
}
h := &hal.Handler{
Method: hal.HEAR,
Pattern: `echo (.+)`,
Usage: "echo <string> - repeats <string> back",
Run: func(res *hal.Response) error {
res.Send(res.Match[1])
},
}
// output:
// > echo foo bar baz
// foo bar baz
}
示例5: Run
func (h *ping) Run(res *hal.Response) error {
return res.Send("PONG")
}
示例6: Topic
// Topic sets the topic
func (a *adapter) Topic(res *hal.Response, strings ...string) error {
for _, str := range strings {
a.conn.SendRawf("TOPIC %s %s", res.Room(), str)
}
return nil
}