utils

package
v0.0.0-...-9dc0c09 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbortWithError

func AbortWithError(c *gin.Context, error *Error)

utility formatting API error to the client

func GenerateNonce

func GenerateNonce() uint32

func GenerateRandomBytes

func GenerateRandomBytes(n uint32) ([]byte, error)

Types

type Error

type Error struct {
	Err struct {
		Code    int           `json:"code"`
		Status  string        `json:"status"`
		Message string        `json:"message"`
		Context []interface{} `json:"context"`
	} `json:"error"`
}

func NewError

func NewError(code int, msg string, context ...interface{}) *Error

func NewUnknownError

func NewUnknownError() *Error

func (*Error) Code

func (err *Error) Code() int

func (*Error) Context

func (err *Error) Context() []interface{}

func (*Error) Error

func (err *Error) Error() string

func (*Error) Message

func (err *Error) Message() string

type SimpleTimeService

type SimpleTimeService struct{}
var DefaultTimeService *SimpleTimeService

func (*SimpleTimeService) Nano

func (t *SimpleTimeService) Nano() int64

func (*SimpleTimeService) Now

func (*SimpleTimeService) Now() time.Time

func (*SimpleTimeService) Unix

func (t *SimpleTimeService) Unix() int64

func (*SimpleTimeService) UnixUint64

func (t *SimpleTimeService) UnixUint64() uint64

type TimeService

type TimeService interface {
	Now() time.Time
}

Jump to

Keyboard shortcuts

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