package api import ( "context" "net/http" "fr.latosa-escrima/api/core" ) func HandleGetUser(w http.ResponseWriter, r *http.Request) { uuid := r.PathValue("user_uuid") var user core.User count, err := core.DB.NewSelect(). Model(&user). Where("user_id = ?", uuid). Limit(1). ScanAndCount(context.Background()) if count == 0 { core.JSONError{ Status: core.Error, Message: "User not found.", }.Respond(w, http.StatusNotFound) return } if err != nil { core.JSONError{ Status: core.Error, Message: err.Error(), }.Respond(w, http.StatusInternalServerError) return } user.Password = "" // TODO : Remove password core.JSONSuccess{ Status: core.Success, Message: "User found.", Data: user, }.Respond(w, http.StatusOK) }