rest

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 16 Imported by: 12

Documentation

Overview

This package implements a reusable REST client

Index

Constants

View Source
const (
	LogLevelDefault   = common.LogLevelDefault
	LogLevelErrorOnly = common.LogLevelErrorOnly
	LogLevelStandard  = common.LogLevelStandard
	LogLevelElevated  = common.LogLevelElevated
	LogLevelFull      = common.LogLevelFull
	LogLevelDebug     = common.LogLevelDebug
	LogLevelTrace     = common.LogLevelTrace
	LogLevelVerbose   = common.LogLevelVerbose
)

please see pkg/common/init.go for more information

Variables

View Source
var (
	// Trace reads an http request or response from rc and writes to w.
	// The content type (kind) should be one of "xml" or "json".
	Trace = func(rc io.ReadCloser, w io.Writer, kind string) io.ReadCloser {
		return debug.NewTeeReader(rc, w)
	}
)

Functions

func Init

func Init(init InitLib)

The SDK Init function for this library. Allows you to set the logging level and use of a log file. Default is output to the stdout.

func InitWithDefault

func InitWithDefault()

InitWithDefault is the SDK Init function for this library using default values.

Types

type Client

type Client struct {
	*HttpClient

	Options interfaces.ClientOptions
}

Client which extends HttpClient to support REST

func New

func New(options interfaces.ClientOptions) *Client

New REST client

func NewWithDefaults

func NewWithDefaults() *Client

NewWithDefaults creates a REST client with default options

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, resBody interface{}) error

Do is a generic REST API call to the platform

type HttpClient

type HttpClient struct {
	http.Client

	UserAgent string
	// contains filtered or unexported fields
}

HttpClient which extends HTTP client

func NewHTTPClient

func NewHTTPClient(options interfaces.ClientOptions) *HttpClient

New allocated a Simple HTTP client

func (*HttpClient) Do

func (c *HttpClient) Do(ctx context.Context, req *http.Request, f func(*http.Response) error) error

Do performs a simple HTTP-style call

type InitLib

type InitLib struct {
	LogLevel      common.LogLevel
	DebugFilePath string
}

Initialization options for this SDK.

Directories

Path Synopsis
This package provides API debugging at the REST/HTTP level
This package provides API debugging at the REST/HTTP level

Jump to

Keyboard shortcuts

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