// UpdateUserHandler handle PUT /users

UpdateUserHandler handle PUT /users
// UpdateUserHandler handle PUT / users
func UpdateUserHandler(c *routing.Context) error {
	userService := getUserService(c)
	requestUser := string(c.Request.Header.Peek("User"))
	if requestUser != c.Param("username") {
		return http.Error(c, "User could not be updated", 400, UsersServiceName())
	}
	usersList := userService.GetUserByUsername(c.Param("username"))
	if len(usersList) == 0 {
		return http.Error(c, "User not found", 404, UsersServiceName())
	}
	user := usersList[0]
	allowedToUpdate := []string{"email", "password"}
	user, err := updateUserUsingUpdateBody(user, c.Request.Body(), allowedToUpdate)
	if err != nil {
		return http.Error(c, "User could not be updated", 400, UsersServiceName())		
	}
	err = userService.UpdateUser(user)
	if err != nil {
		return http.Error(c, "User could not be updated", 400, UsersServiceName())
	} 
	return http.Created(c, "User updated successfuly", UsersServiceName())
}
func UpdateUserHandler ( c * routing . Context ) error { userService := getUserService ( c ) requestUser := string ( c . Request . Header . Peek ( " " ) ) if requestUser != c . Param ( " " ) { return http . Error ( c , " " , 400 , UsersServiceName ( ) ) } usersList := userService . GetUserByUsername ( c . Param ( " " ) ) if len ( usersList ) == 0 { return http . Error ( c , " " , 404 , UsersServiceName ( ) ) } user := usersList [ 0 ] allowedToUpdate := [ ] string { " " , " " } user , err := updateUserUsingUpdateBody ( user , c . Request . Body ( ) , allowedToUpdate ) if err != nil { return http . Error ( c , " " , 400 , UsersServiceName ( ) ) } err = userService . UpdateUser ( user ) if err != nil { return http . Error ( c , " " , 400 , UsersServiceName ( ) ) } return http . Created ( c , " " , UsersServiceName ( ) ) }
UpdateUserHandler handle PUT /users
UpdateUserHandler handle PUT / users
// Get user service
 // Check if user to update is the same as the user that is calling the service
 // Get user by username
 // Update user information
