infra

package
v0.0.0-...-3bf0c7f Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XForwardedFor = "X-Forwarded-For"
	XRealIP       = "X-Real-IP"
)

Variables

View Source
var (
	Config config
)

Functions

func FailedPrecondition

func FailedPrecondition(module, code, message string) *status.Status

func LocalIP

func LocalIP() string

func LoggingInterceptor

func LoggingInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

func NextString

func NextString() (string, error)

func NextUint64

func NextUint64() (uint64, error)

func PwdEncrypt

func PwdEncrypt(pwd string) (encryptPwd, salt string)

func PwdEquals

func PwdEquals(pwd, encryptPwd, salt string) bool

func RecoveryInterceptor

func RecoveryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

func RemoteIp

func RemoteIp(req *http.Request) string

RemoteIp 返回远程客户端的 IP,如 192.168.1.1

func UuidV4

func UuidV4() string

func ValidateInterceptor

func ValidateInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

Types

type App

type App struct {
	Ctx        context.Context
	CancelFunc context.CancelFunc

	GRPCAddr string

	GRPCServer *grpc.Server

	ServeMux    *runtime.ServeMux
	DialOptions []grpc.DialOption
	// contains filtered or unexported fields
}

App application

func NewApp

func NewApp() *App

NewApp new App

func (*App) Run

func (app *App) Run() error

Run run app

type Port

type Port struct {
	HTTP int `yaml:"http"`
	GRPC int `yaml:"grpc"`
}

type Server

type Server struct {
	Swagger bool `yaml:"swagger"`
	Port    Port
}

Jump to

Keyboard shortcuts

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