code: func (m *Messenger) checkIntegrity(r *http.Request) error {
  	if m.appSecret == "" {
  		return fmt.Errorf("missing app secret")
  	}
  
  	sigHeader := "X-Hub-Signature"
  	sig := strings.SplitN(r.Header.Get(sigHeader), "=", 2)
  	if len(sig) == 1 {
  		if sig[0] == "" {
  			return fmt.Errorf("missing %s header", sigHeader)
  		}
  		return fmt.Errorf("malformed %s header: %v", sigHeader, strings.Join(sig, "="))
  	}
  
  	checkSHA1 := func(body []byte, hash string) error {
  		mac := hmac.New(sha1.New, []byte(m.appSecret))
  		if mac.Write(body); fmt.Sprintf("%x", mac.Sum(nil)) != hash {
  			return fmt.Errorf("invalid signature: %s", hash)
  		}
  		return nil
  	}
  
  	body, _ := ioutil.ReadAll(r.Body)
  	r.Body = ioutil.NopCloser(bytes.NewBuffer(body))
  
  	sigEnc := strings.ToLower(sig[0])
  	sigHash := strings.ToLower(sig[1])
  	switch sigEnc {
  	case "sha1":
  		return checkSHA1(body, sigHash)
  	default:
  		return fmt.Errorf("unknown %s header encoding, expected sha1: %s", sigHeader, sig[0])
  	}
  }
docs: // checkIntegrity checks the integrity of the requests received