utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeRequest

func DecodeRequest(w http.ResponseWriter, r *http.Request, log logrus.FieldLogger, req RequestChecker) (ok bool)

DecodeRequest decodes request and checks its validity. It process error if needed

func EncodeResponse

func EncodeResponse(w http.ResponseWriter, r *http.Request, log logrus.FieldLogger, resp interface{}) (ok bool)

EncodeResponse encodes response. It process error if needed

func LogInternalError

func LogInternalError(log logrus.FieldLogger, respMsg string, internalErr error)

func ProcessError

func ProcessError(ctx context.Context, w http.ResponseWriter, respMsg string, code int)

ProcessError writes 'models.Response' with passed message and status code

func ProcessInternalError added in v0.5.0

func ProcessInternalError(ctx context.Context, log logrus.FieldLogger, w http.ResponseWriter,
	respMsg string, err error)

ProcessError logs internal error with 'LogInternalError' and calls 'ProcessError' with 'http.StatusInternalServerError' status code

Types

type RequestChecker

type RequestChecker interface {
	Check() error
}

Jump to

Keyboard shortcuts

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