rest

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package rest provides shared request helpers for the cloud API wrapper packages: context checking, JSON fetching, response nil-checking, and nextPageToken pagination.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(ctx context.Context, method string, urlString string, options []fetch_config.Option) error

Do performs a request with the given method, ignoring the response body.

func DoWithBody

func DoWithBody[B any](
	ctx context.Context,
	method string,
	urlString string,
	body B,
	options []fetch_config.Option,
) error

DoWithBody performs a request with the given method and JSON body, ignoring the response body.

func GetJson

func GetJson[T any](ctx context.Context, urlString string, options []fetch_config.Option) (*T, error)

GetJson performs a GET request and returns the decoded, nil-checked response.

func ListPaginated

func ListPaginated[R any, T any](
	ctx context.Context,
	makeUrlString func(pageToken string) string,
	extract func(response *R) (items []T, nextPageToken string),
	options []fetch_config.Option,
) ([]T, error)

ListPaginated repeatedly performs GET requests, following the page token returned by extract until it is empty, and concatenates the extracted items.

func SendJson

func SendJson[T any, B any](
	ctx context.Context,
	method string,
	urlString string,
	body B,
	options []fetch_config.Option,
) (*T, error)

SendJson performs a request with the given method and JSON body and returns the decoded, nil-checked response.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL