(c *gin.Context)
| 887 | } |
| 888 | |
| 889 | func parsePositiveIntQuery(c *gin.Context) (int, error) { |
| 890 | const key = "limit" |
| 891 | if c == nil { |
| 892 | return 0, nil |
| 893 | } |
| 894 | raw := strings.TrimSpace(c.Query(key)) |
| 895 | if raw == "" { |
| 896 | return 0, nil |
| 897 | } |
| 898 | parsed, err := strconv.Atoi(raw) |
| 899 | if err != nil { |
| 900 | return 0, fmt.Errorf("query parameter %q must be a positive integer: %w", key, err) |
| 901 | } |
| 902 | if parsed <= 0 { |
| 903 | return 0, fmt.Errorf("query parameter %q must be a positive integer: %d", key, parsed) |
| 904 | } |
| 905 | return parsed, nil |
| 906 | } |
| 907 | |
| 908 | func (h *BaseHandlers) nowUTC() time.Time { |
| 909 | if h == nil || h.Now == nil { |
no test coverage detected