metahttp

package
v0.0.0-...-0ca59fa Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete[TResponse any](c *Client, url string, body any, contentType string) (TResponse, error)

Make a HTTP DELETE to the target URL with the specified body and unmarshal the response into the specified type. URL should start with a slash, e.g. "/v0/credentials/123/k8s"

func DeleteJSON

func DeleteJSON[TResponse any](c *Client, url string, body any) (TResponse, error)

Make a HTTP DELETE to the target URL with the specified body (with JSON as mimetype) and unmarshal the response into the specified type. URL should start with a slash, e.g. "/v0/credentials/123/k8s"

func Download

func Download(c *Client, url string, filePath string) (*resty.Response, error)

Download a file from the specified URL to the specified file path. Note: The file gets created even if the request fails.

func Get

func Get[TResponse any](c *Client, url string) (TResponse, error)

Make a HTTP GET to the target URL and unmarshal the response into the specified type. URL should start with a slash, e.g. "/v0/credentials/123/k8s"

func Post

func Post[TResponse any](c *Client, url string, body any, contentType string) (TResponse, error)

Make a HTTP POST to the target URL with the specified body and unmarshal the response into the specified type. URL should start with a slash, e.g. "/v0/credentials/123/k8s"

func PostJSON

func PostJSON[TResponse any](c *Client, url string, body any) (TResponse, error)

Make a HTTP POST to the target URL with the specified body (with JSON as mimetype) and unmarshal the response into the specified type. URL should start with a slash, e.g. "/v0/credentials/123/k8s"

func Put

func Put[TResponse any](c *Client, url string, body any, contentType string) (TResponse, error)

Make a HTTP PUT to the target URL with the specified body and unmarshal the response into the specified type. URL should start with a slash, e.g. "/v0/credentials/123/k8s"

func PutJSON

func PutJSON[TResponse any](c *Client, url string, body any) (TResponse, error)

Make a HTTP PUT to the target URL with the specified body (with JSON as mimetype) and unmarshal the response into the specified type. URL should start with a slash, e.g. "/v0/credentials/123/k8s"

func Request

func Request[TResponse any](c *Client, method string, url string, body any, contentType string) (TResponse, error)

Make a HTTP request to the target URL with the specified method and body, and unmarshal the response into the specified type.

Types

type Client

type Client struct {
	TokenSet *auth.TokenSet // Tokens to use to access the environment.
	BaseURL  string         // Base URL of the target API (e.g. 'https://api.metaplay.io')
	Resty    *resty.Client  // Resty client with authorization header configured.
}

Wrapper object for accessing an environment within a target stack.

func NewJSONClient

func NewJSONClient(tokenSet *auth.TokenSet, baseURL string) *Client

NewJSONClient creates a new HTTP client with the given auth token set and base URL. All failed requests are automatically retried a few times to mitigate network errors.

Jump to

Keyboard shortcuts

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