title: Why do you have to close the body of a request once you have inspected it?
body: <p>I have seen several examples where you read from <code>r.Body</code> and then do a defer <code>r.Body.Close()</code> right after. What will happen if we do not close it?</p>
  
  <p>Lets say I have a <code>http.Handler</code> and inside it I decode the contents of r.Body like this:</p>
  
  <pre><code>func createFeedback(w http.ResponseWriter, r *http.Request) {
      // ... Some code ...
      f := feedback.New()
      if err := json.NewDecoder(r.Body).Decode(f); err != nil {
          return err
      }
      defer r.Body.Close()
      // ... Some more code ...
  }
  </code></pre>
  
  <p>Why do we have to close <code>r.Body</code>?</p>