maidenlanedutils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPayloadSize max size of content
	MaxPayloadSize = 1024 * 1024
)

Variables

This section is empty.

Functions

func AllOrNoneReqd

func AllOrNoneReqd(opts ...string) (ok bool)

AllOrNoneReqd util for checking parameters that must be provided together

func CreateTLSConfiguration

func CreateTLSConfiguration(tlsConfig *TLSConfig) (t *tls.Config, err error)

CreateTLSConfiguration creates a tls.Config structure based on parsing the configuration passed in via a TLSConfig structure

func DefInt

func DefInt(envVarName string, defValue int) int

DefInt defaults an integer to a value in an Env var, and if not the default integer provided

func GetMapString

func GetMapString(genericMap map[string]interface{}, key string) string

GetMapString is a helper to safely extract strings from generic interface maps

func MarshalToYAML

func MarshalToYAML(conf interface{}) (yamlBytes []byte, err error)

MarshalToYAML marshals a JSON annotated structure into YAML, by first going to JSON

func ParseHosts

func ParseHosts(filename string) (map[string]string, error)

ParseHosts - credit to github.com/jaytaylor/go-hostsfile

func StrToAddress

func StrToAddress(desc string, strAddr string) (addr common.Address, err error)

StrToAddress is a helper to parse eth addresses with useful errors

func UUIDv4

func UUIDv4() string

UUIDv4 returns a new UUID V4 as a string

func YAMLorJSONPayload

func YAMLorJSONPayload(req *http.Request) (map[string]interface{}, error)

YAMLorJSONPayload processes either a YAML or JSON payload from an input HTTP request

Types

type HTTPRequester

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

HTTPRequester performs common HTTP request logging/processing for utilities

func NewHTTPRequester

func NewHTTPRequester(name string, conf *HTTPRequesterConf) *HTTPRequester

NewHTTPRequester constructor

func (*HTTPRequester) DoRequest

func (hr *HTTPRequester) DoRequest(method, url string, bodyMap map[string]interface{}) (map[string]interface{}, error)

DoRequest performs a single HTTP request processing the response as JSON

func (*HTTPRequester) GetResponseString

func (hr *HTTPRequester) GetResponseString(m map[string]interface{}, p string, emptyOK bool) (string, error)

GetResponseString returns a string from a response map, asserting its existencer

type HTTPRequesterConf

type HTTPRequesterConf struct {
	Headers map[string][]string `json:"headers"`
}

HTTPRequesterConf configuration for making HTTP reuqests

type TLSConfig

type TLSConfig struct {
	ClientCertsFile    string `json:"clientCertsFile"`
	ClientKeyFile      string `json:"clientKeyFile"`
	CACertsFile        string `json:"caCertsFile"`
	Enabled            bool   `json:"enabled"`
	InsecureSkipVerify bool   `json:"insecureSkipVerify"`
}

TLSConfig is the common TLS config

Jump to

Keyboard shortcuts

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