package httpx import ( "net/http" "strconv" "mtusi2026-messenger/internal/dto" ) func ParsePagination(w http.ResponseWriter, r *http.Request, requestID string) (limit int, cursor *string, ok bool) { q := r.URL.Query() limit = 50 if raw := q.Get("limit"); raw != "" { v, err := strconv.Atoi(raw) if err != nil || v < 1 || v > 100 { WriteError( w, http.StatusBadRequest, dto.ErrorCodeInvalidRequest, "limit must be an integer between 1 and 100", requestID, ) return 0, nil, false } limit = v } if raw := q.Get("cursor"); raw != "" { cursor = &raw } return limit, cursor, true }