Documentation
¶
Overview ¶
Package redirect wraps the /redirect API endpoint — currently just /redirect/list_redirects.json, the per-account inventory of HTTP redirect rules grouped by domain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the api.Client for the /redirect endpoints.
func (*Client) ListRedirects ¶
func (s *Client) ListRedirects(ctx context.Context, request ListRedirectsRequest) (response ListRedirectsResponse, err error)
ListRedirects returns every redirect rule on the account via /redirect/list_redirects.json, grouped by domain → source URL → (destination + HTTP type).
Pagination filters control the result window if the account has a lot of rules.
type ListRedirectsRequest ¶
ListRedirectsRequest paginates / sorts the redirect listing. All fields are optional.
type ListRedirectsResponse ¶
type ListRedirectsResponse struct {
Return map[string]map[string]Rule `json:"return"`
models.APIResponse
}
ListRedirectsResponse is the return from /redirect/list_redirects.json.
**Wire-shape quirk** (verified live, May 2026): when the account has redirects, "return" is a nested map keyed by domain → source URL → Rule:
{
"example.kiwi.nz": {
"a.example.kiwi.nz": {"destination": "https://...", "type": 301},
"b.example.kiwi.nz/blog": {"destination": "https://...", "type": 302}
}
}
When the account has **zero** redirects, "return" is the JSON array `[]`, not the empty object `{}`. The docs only show the populated form, so consumers parsing the obvious map shape would fail on empty accounts.
Custom UnmarshalJSON handles both: the empty array is decoded as an empty map; the populated map is decoded normally.
func (*ListRedirectsResponse) UnmarshalJSON ¶
func (r *ListRedirectsResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON tolerates the empty-array form the API returns when the account has no redirect rules. See type comment.