rest

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MaxWaitTime = 1 * time.Minute
View Source
const MinWaitTime = 5 * time.Second

Variables

View Source
var Logger = logger

Functions

func ContainsViolation

func ContainsViolation(err error, message string) bool

func MicrosecondsToUnixTime

func MicrosecondsToUnixTime(timeInMicroseconds int64) time.Time

MicrosecondsToUnixTime converts the UTC time in microseconds to a time.Time struct (unix time)

func Now

func Now() time.Time

func SetLogWriter

func SetLogWriter(writer io.Writer) error

func StringTimestampToHumanReadableFormat

func StringTimestampToHumanReadableFormat(unixTimestampAsString string) (humanReadable string, parsedTimestamp int64, err error)

StringTimestampToHumanReadableFormat parses and sanity-checks a unix timestamp as string and returns it as int64 and a human-readable representation of it

Types

type Client

type Client interface {
	Get(url string, expectedStatusCodes ...int) Request
	Post(url string, payload any, expectedStatusCodes ...int) Request
	Put(url string, payload any, expectedStatusCodes ...int) Request
	Delete(url string, expectedStatusCodes ...int) Request
}

func DefaultClient

func DefaultClient(envURL string, apiToken string) Client

type ConstraintViolation

type ConstraintViolation struct {
	Description       string `json:"description,omitempty"`
	ParameterLocation string `json:"parameterLocation,omitempty"`
	Message           string `json:"message,omitempty"`
	Path              string `json:"path,omitempty"`
}

type Error

type Error struct {
	Code                 int                   `json:"code"`
	Message              string                `json:"message"`
	ConstraintViolations []ConstraintViolation `json:"constraintViolations,omitempty"`
	URL                  string                `json:"-"`
	Method               string                `json:"-"`
}

func (Error) ContainsViolation

func (me Error) ContainsViolation(message string) bool

func (Error) Error

func (me Error) Error() string

func (Error) ViolationMessage

func (me Error) ViolationMessage() string

type Request

type Request interface {
	Raw() ([]byte, error)
	Finish(v ...any) error
	Expect(codes ...int) Request
	Payload(any) Request
	OnResponse(func(resp *http.Response)) Request
}

Jump to

Keyboard shortcuts

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