func AuthMiddleware(c *mv.Context) { log.Println("Simulate user authentication.") rand.Seed(time.Now().Unix()) if rand.Int()%2 == 0 { c.Response.Write([]byte("User authenticated.\n")) c.Next() } else { c.Response.WriteHeader(http.StatusUnauthorized) c.Response.Write([]byte("Use not authenticated.\n")) c.Abort() } }