func HandleCreateIRLMoji(r render.Render, bindErr binding.Errors, im models.IRLMoji, db *models.DB, backchannel Backchannel) { if bindErr.Count() > 0 { r.JSON(400, JsonErrBinding(bindErr)) return } if backchannel.UserId() == "" { r.JSON(403, JsonErr("The provided credentials were invalid.")) return } user, err := db.GetUserWithId(backchannel.UserId()) if err != nil { r.JSON(403, "Could not find a user with your credentials.") return } // Now let's create that user, shall we? insertedIM, err := db.InsertIM(user.Id, im.Emoji, im.Picture) if err != nil { log.Println("Error creating user:"******"Sorry, an internal server error has occurred.")) return } r.JSON(200, map[string]*models.IRLMoji{"irlmoji": insertedIM}) }