utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustConnGRPC

func MustConnGRPC(ctx context.Context, conn **grpc.ClientConn, addr string)

MustConnGRPC connect grpc client to target address

func MustMapEnv

func MustMapEnv(target *string, envKey string)

MustMapEnv map service address to target address string

func RandomString

func RandomString(length int) string

RandomString generate random string with lower case alphabets and digits

func RespondError

func RespondError(w http.ResponseWriter, code int, msg string) error

RespondError responds to a HTTP request with body of ErrorResponse

func RespondJSON

func RespondJSON(w http.ResponseWriter, data interface{}) error

RespondJSON responds with arbitrary data objects

Types

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

ErrorResponse is a common struct for responding error for HTTP requests

Jump to

Keyboard shortcuts

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