decodeCursor decodes an opaque pagination cursor into the original pageToken struct.
(cursor string)
| 1554 | |
| 1555 | // decodeCursor decodes an opaque pagination cursor into the original pageToken struct. |
| 1556 | func decodeCursor(cursor string) (*pageToken, error) { |
| 1557 | decodedBytes, err := base64.URLEncoding.DecodeString(cursor) |
| 1558 | if err != nil { |
| 1559 | return nil, fmt.Errorf("failed to decode cursor: %w", err) |
| 1560 | } |
| 1561 | |
| 1562 | var token pageToken |
| 1563 | buf := bytes.NewBuffer(decodedBytes) |
| 1564 | decoder := gob.NewDecoder(buf) |
| 1565 | if err := decoder.Decode(&token); err != nil { |
| 1566 | return nil, fmt.Errorf("failed to decode page token: %w, cursor: %v", err, cursor) |
| 1567 | } |
| 1568 | return &token, nil |
| 1569 | } |
| 1570 | |
| 1571 | // paginateList is a generic helper that returns a paginated slice of items |
| 1572 | // from a featureSet. It populates the provided result res with the items |
no test coverage detected
searching dependent graphs…