Преглед изворни кода

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 месец
родитељ
комит
063e3f14f0
1 измењених фајлова са 1 додато и 2 уклоњено
  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) {
 	var categories model.Categories
 	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))
 		if userErr != nil {
 			response.JSONServerError(w, r, userErr)