utils

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SerializationMethodToContentType = map[string]string{
		"json":      "application/json",
		"form":      "application/x-www-form-urlencoded",
		"multipart": "multipart/form-data",
		"raw":       "application/octet-stream",
		"string":    "text/plain",
	}
)

Functions

func AsSecuritySource added in v0.8.0

func AsSecuritySource(security interface{}) func(context.Context) (interface{}, error)

func ConsumeRawBody added in v0.16.0

func ConsumeRawBody(res *http.Response) ([]byte, error)

func Contains

func Contains(slice []string, item string) bool

func GenerateURL

func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, globals interface{}) (string, error)

func MarshalJSON

func MarshalJSON(v interface{}, tag reflect.StructTag, topLevel bool) ([]byte, error)

func MatchContentType

func MatchContentType(contentType string, pattern string) bool

func MatchStatusCodes added in v0.4.0

func MatchStatusCodes(expectedCodes []string, statusCode int) bool

func PopulateHeaders

func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{})

func PopulateQueryParams

func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, globals interface{}) error

func PopulateSecurity added in v0.5.0

func PopulateSecurity(ctx context.Context, req *http.Request, securitySource func(context.Context) (interface{}, error)) error

func ReplaceParameters

func ReplaceParameters(stringWithParams string, params map[string]string) string

func Retry

func Retry(ctx context.Context, r Retries, action func() (*http.Response, error)) (*http.Response, error)

func SerializeRequestBody

func SerializeRequestBody(_ context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error)

func UnmarshalJSON

func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool, disallowUnknownFields bool) error

func UnmarshalJsonFromResponseBody

func UnmarshalJsonFromResponseBody(body io.Reader, out interface{}, tag string) error

Types

type BackoffStrategy deprecated

type BackoffStrategy = retry.BackoffStrategy

Deprecated: Use retry.BackoffStrategy instead.

type Retries

type Retries struct {
	Config      *retry.Config
	StatusCodes []string
}

type RetryConfig deprecated

type RetryConfig = retry.Config

Deprecated: Use retry.Config instead.

Jump to

Keyboard shortcuts

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