func GetUser(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")

	// Get username from path
	a := strings.Split(r.URL.Path, "/")
	id, _ := strconv.Atoi(a[len(a)-1])

	user, err := userRepository.ByID(id)
	if err != nil {
		w.WriteHeader(http.StatusNotFound)
	} else {
		w.WriteHeader(http.StatusOK)
		resBody, _ := json.Marshal(user)
		w.Write(resBody)
	}
}
// GetUser fetches a user if authenticated and exists
GetUser fetches a user if authenticated and exists
// GetUser fetches a user if authenticated and exists
func GetUser(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	a := strings.Split(r.URL.Path, "/")
	id, _ := strconv.Atoi(a[len(a)-1])
	user, err := userRepository.ByID(id)
	if err != nil {
		w.WriteHeader(http.StatusNotFound)
	} else {
		w.WriteHeader(http.StatusOK)
		resBody, _ := json.Marshal(user)
		w.Write(resBody)
	}
}
func GetUser ( w http . ResponseWriter , r * http . Request ) { w . Header ( ) . Set ( " " , " " ) a := strings . Split ( r . URL . Path , " " ) id , _ := strconv . Atoi ( a [ len ( a ) - 1 ] ) user , err := userRepository . ByID ( id ) if err != nil { w . WriteHeader ( http . StatusNotFound ) } else { w . WriteHeader ( http . StatusOK ) resBody , _ := json . Marshal ( user ) w . Write ( resBody ) } }
GetUser fetches a user if authenticated and exists
GetUser fetches a user if authenticated and exists
// Get username from path