func ServeSubmitQuestion(store datastores.QuestionStoreServices) m.HandlerFunc { return func(c *m.Context, w http.ResponseWriter, r *http.Request) { newQuestion := c.ParsedModel.(*models.Question) category := mux.Vars(r)["category"] err := c.RepStore.UpdateRep(category, c.UserID, QUESTION_ASKING_FEE) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) } err, statusCode := store.StoreQuestion(newQuestion.UserID, category, newQuestion.Title, newQuestion.Content) if err != nil { http.Error(w, err.Error(), statusCode) return } w.WriteHeader(http.StatusCreated) } }