utils

package
v0.0.0-...-4475320 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthWrapper

func AuthWrapper(fn server.HandlerFunc) server.HandlerFunc

AuthWrapper is a high-order function which takes a HandlerFunc and returns a function, which takes a context, request and response interface. The token is extracted from the context. If valid, the call is passed along to the handler. If not, an error is returned.

func BcryptCheck

func BcryptCheck(password string, hash string) bool

BcryptCheck compare password and hash

func BcryptEncode

func BcryptEncode(originstr string) string

BcryptEncode encode string to bcrypt crypto string

func EmptyFieldError

func EmptyFieldError(field string) error

emptyFieldError creates an errInvalidField for an empty field

func ExtractContext

func ExtractContext(ctx context.Context, t opentracing.Tracer, name string) opentracing.Span

ExtractContext extract metadata from tracing context and return new span

func GetEnvironment

func GetEnvironment(key, value string) string

GetEnvironment Get a value from an environment variable and return value if no value exists

func InvalidFieldError

func InvalidFieldError(field, reason string) error

invalidFieldError creates an errInvalidField for a specific field and reason

func NewTracer

func NewTracer(serviceName string, addr string) (opentracing.Tracer, io.Closer, error)

NewTracer generate tracer

Types

type ErrInvalidField

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

ErrInvalidField represents a validation error

func (ErrInvalidField) Error

func (e ErrInvalidField) Error() string

Jump to

Keyboard shortcuts

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