asRequestOption returns a function that can be used in (*Client).Request. It modifies the request query parameters.
()
| 113 | // asRequestOption returns a function that can be used in (*Client).Request. |
| 114 | // It modifies the request query parameters. |
| 115 | func (f TokensFilter) asRequestOption() RequestOption { |
| 116 | return func(r *http.Request) { |
| 117 | q := r.URL.Query() |
| 118 | q.Set("include_all", fmt.Sprintf("%t", f.IncludeAll)) |
| 119 | q.Set("include_expired", fmt.Sprintf("%t", f.IncludeExpired)) |
| 120 | r.URL.RawQuery = q.Encode() |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | // Tokens list machine API keys. |
| 125 | func (c *Client) Tokens(ctx context.Context, userID string, filter TokensFilter) ([]APIKeyWithOwner, error) { |