requester

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BadRequestError - the client sent an invalid request
	BadRequestError = &RequestError{"bad request"}
	// ConflictError - the request created a data conflict
	ConflictError = &RequestError{"conflict"}
	// RequestFailedError - the request failed
	RequestFailedError = &RequestError{"request failed"}
	// InvalidResponseError - the response is invalid
	InvalidResponseError = &RequestError{"response invalid"}
	// ServerError - the server returned a 5xx error
	ServerError = &RequestError{"internal server error"}
	// MaxRetriesError - the request has hit the maximum retries
	MaxRetriesError = &RequestError{"maximum retries reached"}
	// ResourceNotFound - the requested resource is not found
	ResourceNotFound = &RequestError{"resource not found"}
	// UnprocessableError - the request was not processable
	UnprocessableError = &RequestError{"unprocessable"}
)

Functions

func Delete

func Delete(url string) ([]byte, error)

Delete - Send a DELETE HTTP request

func DoRequest

func DoRequest(params RequestParams) ([]byte, error)

DoRequest - The underlying function for Get/Post/Put/Delete

func Get

func Get(url string) ([]byte, error)

Get - Send a GET HTTP request

func Post

func Post(url string, params interface{}) ([]byte, error)

Post - Send a POST HTTP request

func Put

func Put(url string, params interface{}) ([]byte, error)

Put - Send a PUT HTTP request

Types

type RequestError

type RequestError struct {
	ErrorString string
}

RequestError - Generic error for requester

func (*RequestError) Error

func (re *RequestError) Error() string

Error - returns the error string

type RequestParams

type RequestParams struct {
	Body         []byte
	URL          string
	Method       string
	RequestToken *string

	MaxRetries    int
	PauseDuration time.Duration

	CacheKey  *string
	CacheTime *time.Duration

	Headers http.Header
}

RequestParams - paramters for the DoRequest function

Jump to

Keyboard shortcuts

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