Exemplo n.º 1
0
func (this *GoogleController) TestHighLoad(ctx framework.WebContext) framework.WebResult {

	n := randomizer.Int63()
	email := fmt.Sprintf("*****@*****.**", 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")
}
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")
}
func (this UserController) Who(ctx framework.WebContext) framework.WebResult {

	return ctx.Text("Anonymous")
}