new endpoint to return product list

This commit is contained in:
Daniel Goc
2026-03-18 11:39:18 +01:00
parent a0dcb56fda
commit 6cebcacb5d
23 changed files with 1243 additions and 66 deletions

View File

@@ -0,0 +1,37 @@
package queryparser
import (
"regexp"
"strconv"
"strings"
"github.com/gofiber/fiber/v3"
)
func ParseQuery(c fiber.Ctx) map[string]interface{} {
queryParams := map[string]interface{}{}
re := regexp.MustCompile(`\?(\w.+)$`)
xx := re.FindAllStringSubmatch(c.Request().URI().String(), -1)
if len(xx) > 0 {
if len(xx[0]) == 2 {
queryParts := strings.Split(xx[0][1], "&")
for _, q := range queryParts {
qq := strings.Split(q, "=")
if len(qq) == 2 {
if num, err := strconv.ParseInt(qq[1], 10, 64); err == nil {
queryParams[qq[0]] = num
} else if float, err := strconv.ParseFloat(qq[1], 64); err == nil {
queryParams[qq[0]] = float
} else {
queryParams[qq[0]] = qq[1]
}
} else {
queryParams[qq[0]] = true
}
}
}
}
return queryParams
}