utils

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: Apache-2.0 Imports: 14 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeJSONResponse

func EncodeJSONResponse(ctx context.Context, i interface{}, status *int, w http.ResponseWriter) error

EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code

func FromBase64

func FromBase64(base64string string) ([]byte, error)

func FromTime added in v0.1.2

func FromTime(t time.Time) string

func GetDefaultTimeZone added in v0.1.2

func GetDefaultTimeZone() string

func IgnoreErrorIfContains

func IgnoreErrorIfContains(ctx context.Context, err error, match string, warningMsg string) error

func IgnoreErrorIfOutputContains

func IgnoreErrorIfOutputContains(ctx context.Context, err error, output string, match string, warningMsg string) error

func InspectStruct

func InspectStruct(ctx context.Context, v interface{}, level int)

func InspectStructV

func InspectStructV(ctx context.Context, val reflect.Value, level int)

func Quiet

func Quiet() func()

func ReadFormFileToTempFile

func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)

ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file

func StructFromMap

func StructFromMap(ctx context.Context, v interface{}, params url.Values) interface{}

StructFromMap -

creates a newStruct to match type of v
loops through the map[key]value matching newStruct.Field=key by name, and setting newStruct.Field=value

func ToBase64

func ToBase64(b []byte) string

func ToTime added in v0.1.2

func ToTime(str string) (time.Time, error)

Types

type Error added in v0.1.2

type Error struct {
	Code int32 `json:"code"`

	Message string `json:"message"`
}

type Route added in v0.1.2

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

A Route defines the parameters for an api endpoint

type Routes added in v0.1.2

type Routes []Route

Routes are a collection of defined api endpoints

Jump to

Keyboard shortcuts

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