MCPcopy Create free account
hub / github.com/buggregator/server / pagination

Function pagination

modules/sentry/api.go:45–62  ·  view source on GitHub ↗

pagination extracts page/limit from query params with defaults.

(r *http.Request, defaultLimit int)

Source from the content-addressed store, hash-verified

43
44// pagination extracts page/limit from query params with defaults.
45func pagination(r *http.Request, defaultLimit int) (limit, offset int) {
46 limit = defaultLimit
47 page := 1
48
49 if v := r.URL.Query().Get("limit"); v != "" {
50 if n, err := strconv.Atoi(v); err == nil && n > 0 && n <= 500 {
51 limit = n
52 }
53 }
54 if v := r.URL.Query().Get("page"); v != "" {
55 if n, err := strconv.Atoi(v); err == nil && n > 0 {
56 page = n
57 }
58 }
59
60 offset = (page - 1) * limit
61 return
62}
63
64func apiJSON(w http.ResponseWriter, v any) {
65 w.Header().Set("Content-Type", "application/json")

Callers 4

handleTracesListFunction · 0.85
handleExceptionsGroupedFunction · 0.85
handleLogsListFunction · 0.85

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected