client

package
v0.0.0-...-f8c2bf4 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

package client provides functionality for building HTTP clients.

Recommended Usage:

type MyClient struct {
	Client *client.Client
}

type ThingInput struct {
}

type ThingOutput struct {
}

func(c MyClient) Thing(input *ThingInput) (*ThingOutput, err) {
	var output ThingOutput
	req := c.Client.NewRequest("GET", "/thing", input, output)
	err := req.Send()
	return output, err
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugLogging

func DebugLogging(c *Client)

DebugLogging adds logging of the enitre request and response.

Types

type Client

type Client struct {
	Info       metadata.ClientInfo // Metadata about this client.
	HTTPClient *http.Client        // Underlying http.Client used to make requests.
	Handlers   request.Handlers    // Handlers to use with requests generated by this client.
}

Client is a request builder.

func New

func New(info metadata.ClientInfo, options ...ClientOpt) *Client

New returns a new client with default Handlers and http client.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, path string, params interface{}, data interface{}) *request.Request

NewRequest builds a request from the client configuration. An http.Request will be initialized with the given context, method and path. A request.Request will be initialized with the http.Request, Handlers, params and data.

type ClientOpt

type ClientOpt func(*Client)

ClientOpt represents a function that will alter the configuration of a Client.

func BasicAuth

func BasicAuth(username, password string) ClientOpt

BasicAuth adds basic auth to every request made by this client.

func RequestSigning

func RequestSigning(id, key string) ClientOpt

RequestSigning adds a handler to sign requests.

func RoundTripper

func RoundTripper(r http.RoundTripper) ClientOpt

RoundTripper sets a custom transport on the underlying http Client.

func Timeout

func Timeout(t time.Duration) ClientOpt

Timeout specifies a time limit for requests made by this Client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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