code: func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc {
  	if realm == "" {
  		realm = "Authorization Required"
  	}
  	realm = "Basic realm=" + strconv.Quote(realm)
  	pairs := processAccounts(accounts)
  	return func(c *Context) {
  		// Search user in the slice of allowed credentials
  		user, found := pairs.searchCredential(c.requestHeader("Authorization"))
  		if !found {
  			// Credentials doesn't match, we return 401 and abort handlers chain.
  			c.Header("WWW-Authenticate", realm)
  			c.AbortWithStatus(http.StatusUnauthorized)
  			return
  		}
  
  		// The user credentials was found, set user's id to key AuthUserKey in this context, the user's id can be read later using
  		// c.MustGet(gin.AuthUserKey).
  		c.Set(AuthUserKey, user)
  	}
  }
docs: // BasicAuthForRealm returns a Basic HTTP Authorization middleware. It takes as arguments a map[string]string where
  // the key is the user name and the value is the password, as well as the name of the Realm.
  // If the realm is empty, "Authorization Required" will be used by default.
  // (see http://tools.ietf.org/html/rfc2617#section-1.2)