util

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2017 License: Apache-2.0 Imports: 19 Imported by: 5

Documentation

Overview

Copyright 2017 Applatix, Inc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(err error, w http.ResponseWriter) error

ErrorHandler is a helper log and write a json error bean to the response

func GenerateSelfSignedCert

func GenerateSelfSignedCert() (crt, key string)

GenerateSelfSignedCert generates self signed certificate and the signing key

func IsUUIDv4

func IsUUIDv4(u string) bool

IsUUIDv4 returns whether or not the string is a UUIDv4

func LogStack

func LogStack()

LogStack will log the current stack

func LogStats

func LogStats()

LogStats will log the current memory usage and number of goroutines

func RegisterStackDumper

func RegisterStackDumper()

RegisterStackDumper will start a goroutine which waits to receive a SIGUSR1 signal and upon receival, dumps stack trace

func StartStatsTicker

func StartStatsTicker(d time.Duration)

StartStatsTicker will start a goroutine which dumps stats at a specified interval

func SuccessHandler

func SuccessHandler(obj interface{}, w http.ResponseWriter)

SuccessHandler is a helper to write an json response success APIs. If obj is nil, returns empty dictionary. If obj is an array or slice, encapsulates it into a json list in a "data" field (e.g. {"data" : []}) For all other cases (structs/maps), returns the object marshaled as json

func TXErrorHandler

func TXErrorHandler(err error, tx interface{}, w http.ResponseWriter) (origerr error)

TXErrorHandler is a helper to rollback a transaction and write a json error to the response

Types

This section is empty.

Jump to

Keyboard shortcuts

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