func (a *API) FetchUser(cid CIDType) (*User, error) {
	var userCID string

	if cid == nil || *cid == "" {
		userCID = config.UserPrefix + "/current"
	} else {
		userCID = string(*cid)
	}

	matched, err := regexp.MatchString(config.UserCIDRegex, userCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid user CID [%s]", userCID)
	}

	result, err := a.Get(userCID)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] fetch user, received JSON: %s", string(result))
	}

	user := new(User)
	if err := json.Unmarshal(result, user); err != nil {
		return nil, err
	}

	return user, nil
}
func (a *API) FetchUser(cid CIDType) (*User, error) {
	var userCID string

	if cid == nil || *cid == "" {
		userCID = config.UserPrefix + "/current"
	} else {
		userCID = string(*cid)
	}

	matched, err := regexp.MatchString(config.UserCIDRegex, userCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid user CID [%s]", userCID)
	}

	result, err := a.Get(userCID)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] fetch user, received JSON: %s", string(result))
	}

	user := new(User)
	if err := json.Unmarshal(result, user); err != nil {
		return nil, err
	}

	return user, nil
}
func ( a * API ) FetchUser ( cid CIDType ) ( * User , error ) { var userCID string if cid == nil || * cid == " " { userCID = config . UserPrefix + " " } else { userCID = string ( * cid ) } matched , err := regexp . MatchString ( config . UserCIDRegex , userCID ) if err != nil { return nil , err } if ! matched { return nil , fmt . Errorf ( " " , userCID ) } result , err := a . Get ( userCID ) if err != nil { return nil , err } if a . Debug { a . Log . Printf ( " " , string ( result ) ) } user := new ( User ) if err := json . Unmarshal ( result , user ) ; err != nil { return nil , err } return user , nil }
// FetchUser retrieves user with passed cid. Pass nil for '/user/current'.
FetchUser retrieves user with passed cid . Pass nil for / user / current .