-1

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?

j08691
  • 204,283
  • 31
  • 260
  • 272

2 Answers2

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
0

Use

c.FullPath()

for get current URL path