api

package
v1.1.35 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 17 Imported by: 6

Documentation

Index

Constants

HTTP const definitions

Variables

This section is empty.

Functions

func SetConfigAgent

func SetConfigAgent(env string, isGRPC, isDocker bool, agentName, singleURL string, singleEntryFilter []string)

SetConfigAgent -

Types

type Client

type Client interface {
	Send(request Request) (*Response, error)
}

Client -

func NewClient

func NewClient(cfg config.TLSConfig, proxyURL string) Client

NewClient - creates a new HTTP client

func NewClientWithTimeout

func NewClientWithTimeout(tlsCfg config.TLSConfig, proxyURL string, timeout time.Duration) Client

NewClientWithTimeout - creates a new HTTP client, with a timeout

func NewSingleEntryClient

func NewSingleEntryClient(tlsCfg config.TLSConfig, proxyURL string, timeout time.Duration) Client

NewSingleEntryClient - creates a new HTTP client for single entry point with a timeout

type MockHTTPClient

type MockHTTPClient struct {
	Client
	Response      *Response // this for if you want to set your own dummy response
	ResponseCode  int       // this for if you only care about a particular response code
	ResponseError error

	RespCount int
	Responses []MockResponse
	Requests  []Request // lists all requests the client has received
	sync.Mutex
}

MockHTTPClient - use for mocking the HTTP client

func (*MockHTTPClient) Send

func (c *MockHTTPClient) Send(request Request) (*Response, error)

Send -

func (*MockHTTPClient) SetResponse

func (c *MockHTTPClient) SetResponse(filepath string, code int)

SetResponse - if you care about the response content and the code, pass both in if you only care about the code, pass "" for the filepath

func (*MockHTTPClient) SetResponses

func (c *MockHTTPClient) SetResponses(responses []MockResponse)

SetResponses - if you care about the response content and the code, pass both in if you only care about the code, pass "" for the filepath

type MockResponse

type MockResponse struct {
	FileName  string
	RespData  string
	RespCode  int
	ErrString string
}

MockResponse - use for mocking the MockHTTPClient responses

type Request

type Request struct {
	Method      string
	URL         string
	QueryParams map[string]string
	Headers     map[string]string
	Body        []byte
	FormData    map[string]string
}

Request - the request object used when communicating to an API

type Response

type Response struct {
	Code    int
	Body    []byte
	Headers map[string][]string
}

Response - the response object given back when communicating to an API

Jump to

Keyboard shortcuts

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