title: Go-Gin read request body many times
body: <p>I am trying to restore the context with it's data after performing validation on it's data.I need the data to keep moving as need it later on in the next function.</p>
  <p>I am new to golang and the below code is as far I could go. any help and a better approach is much appreciated.</p>
  <p>thanks in advance.</p>
  <p>the validation middleware</p>
  <pre><code>func SignupValidator(c *gin.Context) {
      // Read the Body content
      // var bodyBytes []byte
      // if c.Request.Body != nil {
      //  bodyBytes, _ = ioutil.ReadAll(c.Request.Body)
      // }
      var user entity.User
      if err := c.ShouldBindJSON(&amp;user); err != nil {
           validate := validator.New()
           if err := validate.Struct(&amp;user); err != nil {
                c.JSON(http.StatusBadRequest, gin.H{
                   &quot;error&quot;: err.Error(),
            })
            c.Abort()
            return
          }
          // c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))
      }
      // Read the Body content
      var bodyBytes []byte
      if c.Request.Body != nil {
          bodyBytes, _ = ioutil.ReadAll(c.Request.Body)
      }
      fmt.Println(string(bodyBytes)) // this empty
      c.Next()
  
  }
  </code></pre>
  <p>route</p>
  <pre><code>auth.POST(&quot;login&quot;, gin.Logger(), validations.SignupValidator, func(ctx *gin.Context) {
              ctx.JSON(200, videoController.Save(ctx))
          })
  </code></pre>