當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Response.Send方法代碼示例

本文整理匯總了Golang中github.com/djosephsen/hal.Response.Send方法的典型用法代碼示例。如果您正苦於以下問題:Golang Response.Send方法的具體用法?Golang Response.Send怎麽用?Golang Response.Send使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/djosephsen/hal.Response的用法示例。


在下文中一共展示了Response.Send方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Run

func (h *ikr) Run(res *hal.Response) error {
	now := time.Now()
	rand.Seed(int64(now.Unix()))
	//only fire half the time
	if rand.Intn(100) >= 50 {
		return nil
	}
	replies := []string{
		"*I know right?!*",
		"*OMG* couldn't agree more",
		":+1:",
		"+1",
		":arrow_up: THAT",
		":arrow_up: you complete me :arrow_up:",
		"so true",
		"agreed.",
		"that's the fact jack",
		"YUUUUUUP",
		"that's what I'm talkin bout",
		"*IKR?!*",
		"singit",
		"^droppin the truth bombs :boom: :boom: :boom:",
		"#legit",
		"/me nodds emphatically in agreement",
		"for REALZ though",
		"FOR REALSIES",
		"it's like you *literally* just read my mind right now",
	}

	reply := replies[rand.Intn(len(replies)-1)]
	hal.Logger.Debug(" *** ikr:Sending response: %s", reply)
	res.Send(reply)
	return nil
}
開發者ID:mjbrender,項目名稱:hustlebot,代碼行數:34,代碼來源:ikr.go

示例2: 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
}
開發者ID:mjbrender,項目名稱:hustlebot,代碼行數:16,代碼來源:handler_test.go

示例3: Run

func (h *ping) Run(res *hal.Response) error {
	return res.Send("PONG")
}
開發者ID:mjbrender,項目名稱:hustlebot,代碼行數:3,代碼來源:ping.go


注:本文中的github.com/djosephsen/hal.Response.Send方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。