func SlowRequest(duration time.Duration) gin.HandlerFunc {
	return func(c *gin.Context) {
		start := time.Now()
		c.Next()
		wait := duration - time.Since(start)
		time.Sleep(wait)
	}
}
SlowRequest introduces delay
package middleware
import (
	"time"
	"github.com/gin-gonic/gin"
)