asRequestOption returns a function that can be used in (*Client).Request. It modifies the request query parameters.
()
| 29 | // asRequestOption returns a function that can be used in (*Client).Request. |
| 30 | // It modifies the request query parameters. |
| 31 | func (p Pagination) asRequestOption() RequestOption { |
| 32 | return func(r *http.Request) { |
| 33 | q := r.URL.Query() |
| 34 | if p.AfterID != uuid.Nil { |
| 35 | q.Set("after_id", p.AfterID.String()) |
| 36 | } |
| 37 | if p.Limit > 0 { |
| 38 | q.Set("limit", strconv.Itoa(p.Limit)) |
| 39 | } |
| 40 | if p.Offset > 0 { |
| 41 | q.Set("offset", strconv.Itoa(p.Offset)) |
| 42 | } |
| 43 | r.URL.RawQuery = q.Encode() |
| 44 | } |
| 45 | } |