Documentation
¶
Index ¶
- Constants
- Variables
- func GenGinLoggerFields(c *gin.Context) logrus.Fields
- func GetClientIP(c *gin.Context) string
- func GetPrivateKey() *rsa.PrivateKey
- func GetPublicKey() *rsa.PublicKey
- func GetPublicKeyStr() string
- func GetUserAgent(c *gin.Context) string
- func InitDB() (*gorm.DB, func(), error)
- func InitGinEngine() *gin.Engine
- func InitLogger() *logrus.Logger
- func InitLogrus() *logrus.Logger
- func InitLogrusEntry() *logrus.Entry
- func InitPrometheusRegistry() *prometheus.Registry
- func InitRedis() (*redis.Client, func(), error)
- func InitTracer() *jConfig.Configuration
- func InitVault()
- func InitWebSocket() *websocket.Upgrader
- func LoadEnv() string
- func LogFailure(code ext.Code, desc string, err error)
- func LogSuccess(desc string)
- func LoggerForHTTP() gin.HandlerFunc
- func LoggerForRPC(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, ...) (interface{}, error)
- func SelectFromMetadata(md metadata.MD, key string) string
- func SetHeadersForDownstream(c *gin.Context, downstreamName string) error
- func SetMetadataForDownstreamFromHttpHeaders(ctx context.Context, c *gin.Context, downstreamName string) (context.Context, error)
- func ValidateHeaders(c *gin.Context) error
- func ValidateMetadata(md metadata.MD) error
- type Config
- func (cfg *Config) ConvertRSAKeys()
- func (cfg *Config) GetSecret()
- func (cfg *Config) HandleLoadedConfig()
- func (cfg *Config) LoadConfig(configFile string)
- func (cfg *Config) LoadSecret()
- func (cfg *Config) PutAppSecret()
- func (cfg *Config) PutRSA()
- func (cfg *Config) PutSalt()
- func (cfg *Config) SetRSAKeys()
- type CustomClaims
- type GormLogger
- func (l *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
- func (l *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
- func (l *GormLogger) LogMode(lev logger.LogLevel) logger.Interface
- func (l *GormLogger) Trace(ctx context.Context, begin time.Time, ...)
- func (l *GormLogger) Warn(ctx context.Context, msg string, data ...interface{})
- type IRocketMQ
- type Jwt
- type RocketMQ
Constants ¶
View Source
const ( SUCCESS = "成功" FAILURE = "失败" )
logger
View Source
const ( KV = "kv" PWD = "pwd" RSA = "rsa" JWT = "jwt" SECRET = "secret" SALT = "salt" PUK = "puk" PRK = "prk" ID = "id" APP = "app" )
vault
View Source
const ( Bearer = "Bearer " UserID = "userID" // headers params Method = "method" URI = "uri" ClientIp = "client_ip" UserAgent = "user-agent" TraceId = "trace_id" SpanId = "span_id" ParentId = "parent_id" Authorization = "authorization" AppId = "app_id" RequestId = "request_id" UserId = "user_id" RequestURI = "request_uri" Signature = "signature" // jaeger UberTraceId = "uber-trace-id" // redis Nonce = "nonce" // pool MyWsConn = "MyWsConn" )
View Source
const ( TokenExpired = "Token已过期" TokenNotValidYet = "Token不再有效" TokenMalformed = "Token非法" TokenInvalid = "Token无效" )
View Source
const ( Username = "liuzhao" Password = "123456" )
vault access
Variables ¶
Functions ¶
func GetClientIP ¶
func GetPrivateKey ¶
func GetPrivateKey() *rsa.PrivateKey
func GetPublicKey ¶
func GetPublicKeyStr ¶
func GetPublicKeyStr() string
func GetUserAgent ¶
func InitLogrusEntry ¶
func InitPrometheusRegistry ¶
func InitPrometheusRegistry() *prometheus.Registry
func InitTracer ¶
func InitTracer() *jConfig.Configuration
func InitWebSocket ¶
func LogSuccess ¶
func LogSuccess(desc string)
func LoggerForRPC ¶
func LoggerForRPC( ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (interface{}, error)
RPC 日志中间件
func SetHeadersForDownstream ¶
func ValidateHeaders ¶
func ValidateMetadata ¶
Types ¶
type Config ¶
type Config struct { App app Lib lib Server server Secret secret Downstreams []downstream }
func (*Config) ConvertRSAKeys ¶
func (cfg *Config) ConvertRSAKeys()
func (*Config) GetSecret ¶
func (cfg *Config) GetSecret()
GetSecret 使用client token访问vault,获取secret,存入配置对象
func (*Config) HandleLoadedConfig ¶
func (cfg *Config) HandleLoadedConfig()
func (*Config) SetRSAKeys ¶
func (cfg *Config) SetRSAKeys()
type CustomClaims ¶
type GormLogger ¶
func InitGormLogger ¶
func InitGormLogger() *GormLogger
func (*GormLogger) Error ¶
func (l *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
func (*GormLogger) Info ¶
func (l *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
Click to show internal directories.
Click to hide internal directories.