I want to do a A/B test in a Gin's middleware, I want to pass url:usermeta
as a key-value to the A/B test service. How can I achieve this goal?Or any other grace way?
Asked
Active
Viewed 2,331 times
-1

j08691
- 204,283
- 31
- 260
- 272

Felix Septem
- 43
- 8
2 Answers
0
I suppose you want to add a new functional middleware and test it in A/B style.
func ServiceMiddleWare() gin.HandleFunc {
return func(c *gin.Context){
r := rand.New(rand.NewSource(time.Now().UnixNano()))
if r.Intn(100) < 50 {
c.Next()
return
}
// service_logic
fmt.Println("add a new service")
c.Next()
}
}

fwhez
- 561
- 4
- 10
-
not simple random strategy, sometimes related with user's metadata – Felix Septem Jan 29 '19 at 09:11