func GetDB(ctx context.Context) *gorm.DB {
	db, _ := ctx.Value(ctxKeyDB).(*gorm.DB)
	return db
}
GetDB returns the DB associated with the context, or nil.
package lib
import (
	"context"
	"net/http"
	"github.com/go-redis/redis"
	"github.com/jinzhu/gorm"
	"go.uber.org/zap"
)
type ctxKey string
const (
	ctxKeyLogger     ctxKey = "logger"
	ctxKeyDB         ctxKey = "db"
	ctxKeyRedis      ctxKey = "redis"
	ctxKeyRender     ctxKey = "render"
	ctxKeyHttpClient ctxKey = "httpclient"
)
func GetLogger(ctx context.Context) *zap.Logger {
	if ctx == nil {
		ctx = context.Background()
	}
	if l, ok := ctx.Value(ctxKeyLogger).(*zap.Logger); ok {
		return l
	}
	return zap.L()
}
func WithLogger(ctx context.Context, l *zap.Logger) context.Context {
	return context.WithValue(ctx, ctxKeyLogger, l)
}
func WithNamedLogger(ctx context.Context, name string) context.Context {
	return context.WithValue(ctx, ctxKeyLogger, GetLogger(ctx).Named(name))
}
func WithLoggerFields(ctx context.Context, f ...zap.Field) context.Context {
	return context.WithValue(ctx, ctxKeyLogger, GetLogger(ctx).With(f...))
}