Przeglądaj źródła

refactor(api): parse counts parameter with QueryBoolParam

The categories handler parsed the counts query parameter by comparing
the raw string to "true". Use QueryBoolParam for consistency with the
other boolean query parameters in the package.
Frédéric Guillot 1 dzień temu
rodzic
commit
063e3f14f0
1 zmienionych plików z 1 dodań i 2 usunięć
  1. 1 2
      internal/api/category_handlers.go

+ 1 - 2
internal/api/category_handlers.go

@@ -112,9 +112,8 @@ func (h *handler) markCategoryAsReadHandler(w http.ResponseWriter, r *http.Reque
 func (h *handler) getCategoriesHandler(w http.ResponseWriter, r *http.Request) {
 func (h *handler) getCategoriesHandler(w http.ResponseWriter, r *http.Request) {
 	var categories model.Categories
 	var categories model.Categories
 	var err error
 	var err error
-	includeCounts := request.QueryStringParam(r, "counts", "false")
 
 
-	if includeCounts == "true" {
+	if request.QueryBoolParam(r, "counts", false) {
 		user, userErr := h.store.UserByID(request.UserID(r))
 		user, userErr := h.store.UserByID(request.UserID(r))
 		if userErr != nil {
 		if userErr != nil {
 			response.JSONServerError(w, r, userErr)
 			response.JSONServerError(w, r, userErr)