func getId(r *http.Request) int { id, err := strconv.Atoi(mux.Vars(r)["id"]) // This will return a 500 instead of 404 because we have parameter // validation in routes.go that only allows numbers for id. If there // is an error here, it is something different and most likely a 500. util.CheckErr(err) return id }
func getFormInt(fieldName string, r *http.Request) int { // TODO this error handling will probably need to be different. i, err := strconv.Atoi(r.PostForm.Get(fieldName)) util.CheckErr(err) return i }