Пример #1
0
func createGroup(groupId string, b io.Reader) (group *types.Group, err error) {
	group = new(types.Group)

	if err = json.NewDecoder(b).Decode(&group); err != nil {
		return nil, err
	}
	if groupId != "" {
		group.Id = groupId
	} else {
		group.Id = util.GetUUID()
	}
	created := time.Now()
	group.Meta.Created = created.Format(time.RFC3339)
	group.Meta.LastModified = group.Meta.Created
	group.Meta.Location =
		fmt.Sprintf("http://%s:%d/%s/Groups/%s", hostFlag, portFlag, SCIM_VERSION, group.Id)

	return group, nil
}
Пример #2
0
// Create a user data structure from incoming request body, then return a User struct that
// represent incoming user info in JSON payload
func createUser(userId string, b io.Reader) (user *types.User, err error) {
	user = new(types.User)

	if err = json.NewDecoder(b).Decode(&user); err != nil {
		return nil, err
	}
	// Generate metadata
	if userId != "" {
		user.Id = userId
	} else {
		user.Id = util.GetUUID()
	}
	created := time.Now()
	user.Meta.Created = created.Format(time.RFC3339)
	user.Meta.LastModified = user.Meta.Created
	user.Meta.Location =
		fmt.Sprintf("http://%s:%d/%s/Users/%s", hostFlag, portFlag, SCIM_VERSION, user.Id)

	return user, nil
}