本文整理匯總了Golang中einvite/framework.WebContext.Text方法的典型用法代碼示例。如果您正苦於以下問題:Golang WebContext.Text方法的具體用法?Golang WebContext.Text怎麽用?Golang WebContext.Text使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類einvite/framework.WebContext
的用法示例。
在下文中一共展示了WebContext.Text方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestHighLoad
func (this *GoogleController) TestHighLoad(ctx framework.WebContext) framework.WebResult {
n := randomizer.Int63()
email := fmt.Sprintf("user%[email protected]", n)
name := fmt.Sprintf("User %d", n)
dto := &contracts.User{Email: email, Name: name}
credentials := &contracts.UserAuthCredentials{
Type: framework.AuthType_Google,
AccessToken: fmt.Sprintf("Access token for user %s", name),
RefreshToken: fmt.Sprintf("Refresh token for user %s", name),
Expiry: time.Now().Add(1 * time.Hour),
}
_, err := this.userService.SaveWithCredentials(dto, credentials)
if err != nil {
log.Println(err)
return ctx.Error(err)
}
session := ctx.Session()
session.SetUser(&framework.SessionUser{
UserId: email,
AuthType: framework.AuthType_Google,
AuthData: credentials.AccessToken,
})
return ctx.Text("OK")
}
示例2: Test
func (this EventController) Test(ctx framework.WebContext) framework.WebResult {
//note: time.sleep frees the thread and allows other goroutines to execute
//sending 1000 concurrent requests with AB all complete within 5seconds
time.Sleep(1 * time.Second)
fmt.Println(ctx.Header())
fmt.Println("Test invoked")
return ctx.Text("test operation")
}
示例3: Who
func (this UserController) Who(ctx framework.WebContext) framework.WebResult {
return ctx.Text("Anonymous")
}