httpclnt

package
v1.26.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Get makes a get request
	Get(ctx context.Context, req Request) (Response, error)
	// Post makes a post request
	Post(ctx context.Context, req Request) (Response, error)
	// Put makes a put request
	Put(ctx context.Context, req Request) (Response, error)
}

Client allows making http requests

func NewDefaultClient

func NewDefaultClient() (Client, error)

NewDefaultClient creates an instance of Client

type DefaultClient

type DefaultClient struct{}

DefaultClient defines the default and basic handler to make requests

func (*DefaultClient) Get

func (c *DefaultClient) Get(ctx context.Context, req Request) (Response, error)

Get makes a get request

func (*DefaultClient) Post

func (c *DefaultClient) Post(ctx context.Context, req Request) (Response, error)

Post makes a post request

func (*DefaultClient) Put

func (c *DefaultClient) Put(ctx context.Context, req Request) (Response, error)

Put makes a put request

type DefaultRequest

type DefaultRequest struct {
	// contains filtered or unexported fields
}

DefaultRequest defines the default and basic instance of a request

func (*DefaultRequest) AddHeader

func (r *DefaultRequest) AddHeader(header string, value string)

AddHeader adds custom headers to the request

func (*DefaultRequest) GetHeaders

func (r *DefaultRequest) GetHeaders() map[string]string

GetHeaders returns all configured headers

func (*DefaultRequest) GetPayload

func (r *DefaultRequest) GetPayload() ([]byte, error)

GetPayload returns the payload of the request

func (*DefaultRequest) GetURL

func (r *DefaultRequest) GetURL() string

GetURL returns the URL of the request

type DefaultResponse

type DefaultResponse struct {
	// contains filtered or unexported fields
}

DefaultResponse defines the default and basic instance of a response

func (*DefaultResponse) GetBody

func (r *DefaultResponse) GetBody() []byte

GetBody returns the payload of the response

func (*DefaultResponse) GetStatusCode

func (r *DefaultResponse) GetStatusCode() int

GetStatusCode returns the http code of the response

type Request

type Request interface {
	// AddHeader adds custom headers to the request
	AddHeader(header string, value string)
	// GetHeaders returns all configured headers
	GetHeaders() map[string]string
	// GetPayload returns the payload of the request
	GetPayload() ([]byte, error)
	// GetURL returns the URL of the request
	GetURL() string
}

Request holds all the information to make a http request

func NewDefaultRequest

func NewDefaultRequest(
	url string,
	payload interface{},
) (Request, error)

NewDefaultRequest creates an instance of Request

type Response

type Response interface {
	// GetStatusCode returns the http code of the response
	GetStatusCode() int
	// GetBody returns the payload of the response
	GetBody() []byte
}

Response holds all the information from a http response

func NewDefaultResponse

func NewDefaultResponse(statusCode int, body []byte) (Response, error)

NewDefaultResponse creates a new instance of Response

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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