util

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateMAC

func CalculateMAC(message, key []byte) []byte

CalculateMAC calculate the HMAC

func DeepCopyMapParam

func DeepCopyMapParam(param map[string]interface{}) map[string]interface{}

DeepCopyMapParam returns a deep copied map param object

func DeepCopyParam

func DeepCopyParam(param interface{}) interface{}

DeepCopyParam returns a deep copied json param object

func GetBoolParam

func GetBoolParam(param map[string]interface{}, name string) (bool, error)

GetBoolParam get the bool param from the map

func GetIntParam

func GetIntParam(param map[string]interface{}, name string) (int, error)

GetIntParam get the int param from the map

func GetMapParam

func GetMapParam(param map[string]interface{}, name string) (map[string]interface{}, error)

GetMapParam get the map param from the map

func GetNestedMapValue

func GetNestedMapValue(param map[string]interface{}, nestedKey string) (interface{}, error)

GetNestedMapValue get the value of a nested key from the map map["a/b/c"] = map["a"]["b"]["c"]

func GetStringParam

func GetStringParam(param map[string]interface{}, name string) (string, error)

GetStringParam get the string param from the map

func GetStringSliceParam

func GetStringSliceParam(param map[string]interface{}, name string) ([]string, error)

GetStringSliceParam get the string slice param from the map (string or slice of strings)

func GogsParam

func GogsParam(param map[string]interface{}) map[string]interface{}

GogsParam will choose some important params

func InterfaceMapToStringMap

func InterfaceMapToStringMap(param interface{}) interface{}

InterfaceMapToStringMap will only keep map with string keys

func JSONToMap

func JSONToMap(text []byte) (map[string]interface{}, error)

JSONToMap convert json to map

func MergeMapParam

func MergeMapParam(mapOrigin, mapNew map[string]interface{})

MergeMapParam merges the two maps

func ValidateMAC

func ValidateMAC(message, messageMAC, key []byte) bool

ValidateMAC checks the validation of message based on the key

Types

type BaseLogger

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

BaseLogger is a basic struct implement LoggerSetter

func (*BaseLogger) Debugf

func (l *BaseLogger) Debugf(f string, v ...interface{})

Debugf log debug output

func (*BaseLogger) Errorf

func (l *BaseLogger) Errorf(f string, v ...interface{})

Errorf log error output

func (*BaseLogger) Infof

func (l *BaseLogger) Infof(f string, v ...interface{})

Infof log info output

func (*BaseLogger) SetLogger

func (l *BaseLogger) SetLogger(logger interface{})

SetLogger will set logger

func (*BaseLogger) Warnf

func (l *BaseLogger) Warnf(f string, v ...interface{})

Warnf log warn output

type HTTPServer

type HTTPServer struct {
	BaseLogger
	UnixSocket   string
	Host         string
	Port         int
	ServerHeader string
	ValidateFunc func(*http.Request, []byte) error
	ProcessFunc  func(http.ResponseWriter, *http.Request, []byte)
	// contains filtered or unexported fields
}

HTTPServer is a trigger which will listen to http request

func (*HTTPServer) Start

func (h *HTTPServer) Start()

Start the http server

func (*HTTPServer) Stop

func (h *HTTPServer) Stop()

Stop the http server

Jump to

Keyboard shortcuts

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