public

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidatorKey        = "ValidatorKey"
	TranslatorKey       = "TranslatorKey"
	AdminSessionInfoKey = "AdminSessionInfoKey"

	LoadTypeHTTP = 0
	LoadTypeTCP  = 1
	LoadTypeGRPC = 2

	HTTPRuleTypePrefixURL = 0
	HTTPRuleTypeDomain    = 1

	//flow_counter_store
	RedisFlowDayKey  = "flow_day_count"
	RedisFlowHourKey = "flow_hour_count"

	//flow_limit && http_flow_limit function app&server's name or prefix
	FlowTotal         = "flow_total"
	FlowServicePrefix = "flow_service_"
	FlowAppPrefix     = "flow_app_"

	//distributed limter prefix
	DistributedLimiterPrefix = "dist_limiter_"

	JwtSignKey = "my_sign_key"
	JwtExpires = 60 * 60

	//middleware context key
	ServiceDetailContextKey = "service"
)

Variables

View Source
var (
	LoadTypeMap = map[int]string{
		LoadTypeHTTP: "HTTP",
		LoadTypeTCP:  "TCP",
		LoadTypeGRPC: "GRPC",
	}
)

Functions

func DefaultGetValidParams added in v1.0.0

func DefaultGetValidParams(c *gin.Context, params interface{}) error

func GenSaltPassword added in v1.0.0

func GenSaltPassword(salt, password string) string

func GetGinTraceContext

func GetGinTraceContext(c *gin.Context) *trace.Trace

func GetTranslation added in v1.0.0

func GetTranslation(c *gin.Context) (ut.Translator, error)

func GetValidator added in v1.0.0

func GetValidator(c *gin.Context) (*validator.Validate, error)

func GinLogNotice added in v1.0.0

func GinLogNotice(c *gin.Context, dltag string, m map[string]interface{})

func GinLogWarning added in v1.0.0

func GinLogWarning(c *gin.Context, dltag string, m map[string]interface{})

func HTTPPathsValidate added in v1.0.0

func HTTPPathsValidate(httpPaths string) error

func InArrayString added in v1.0.0

func InArrayString(s string, arr []string) bool

func InIPSliceStr added in v1.0.0

func InIPSliceStr(targetIP, ipSliceStr string) bool

func JwtDecode added in v1.0.0

func JwtDecode(tokenString string) (*jwt.StandardClaims, error)

func JwtEncode added in v1.0.0

func JwtEncode(claims jwt.StandardClaims) (string, error)

func MD5

func MD5(s string) string

MD5 md5加密

func Obj2Json added in v1.0.0

func Obj2Json(s interface{}) string

func RedisConfDo

func RedisConfDo(commandName string, args ...interface{}) (interface{}, error)

func RedisConfPipline

func RedisConfPipline(pip ...func(c redis.Conn)) error

func ResponseError

func ResponseError(c *gin.Context, code ResponseCode, err error)

func ResponseSuccess

func ResponseSuccess(c *gin.Context, data interface{})

func ServiceNameValidate added in v1.0.0

func ServiceNameValidate(serviceName string) error

func UpstreamListValidate added in v1.0.0

func UpstreamListValidate(upstreamList string) error

Types

type Response

type Response struct {
	ErrorCode ResponseCode `json:"errno"`
	ErrorMsg  string       `json:"errmsg"`
	Data      interface{}  `json:"data"`
	TraceId   interface{}  `json:"trace_id"`
	Stack     interface{}  `json:"stack"`
}

type ResponseCode

type ResponseCode int
const (
	SuccessCode ResponseCode = iota
	UndefErrorCode
	ValidErrorCode
	InternalErrorCode
	InvalidRequestErrorCode ResponseCode = 401
	CustomizeCode           ResponseCode = 1000
	GROUPALL_SAVE_FLOWERROR ResponseCode = 2001
)

1000以下为通用码,1000以上为用户自定义码

Jump to

Keyboard shortcuts

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