func ServeSortedQuestions(store datastores.QuestionStoreServices) m.HandlerFunc { return func(c *m.Context, w http.ResponseWriter, r *http.Request) { routeVars := mux.Vars(r) questions, err, statusCode := store.SortQuestions(routeVars["postComponent"], routeVars["sortedBy"], routeVars["order"], routeVars["offset"]) if err != nil { http.Error(w, err.Error(), statusCode) return } services.PrintJSON(w, questions) } }