common

package
v0.0.0-...-0c811c1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ENV = new(starmap)
)

config(s)

Functions

func FreshJWT

func FreshJWT(t *UserJWT, freshD time.Duration, termD time.Duration) (string, error)

FreshJWT if will expire

func GetGormRepo

func GetGormRepo(ctx context.Context) (*gorm.DB, bool)

GetGormRepo from ctx

func GetMongoRepo

func GetMongoRepo(ctx context.Context) (*mgo.Session, bool)

GetMongoRepo from ctx

func GormRepo

func GormRepo(service micro.Service, repo *gorm.DB) server.HandlerWrapper

GormRepo Wrapper

func ItemInList

func ItemInList(a string, b []string) bool

ItemInList util

func MongoRepo

func MongoRepo(service micro.Service) (wrapper server.HandlerWrapper, deferFn func())

MongoRepo Wrapper

Types

type Model

type Model struct {
	// ID        uint `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

Model for gorm (sub-model needs have column `Id`)

func (*Model) BeforeCreate

func (*Model) BeforeCreate(scope *gorm.Scope) error

BeforeCreate for gorm

type RepoKey

type RepoKey struct {
	// contains filtered or unexported fields
}

RepoKey for Context Value

type RepoKeyT

type RepoKeyT int

RepoKeyT for RepoKey

const (
	CKMongoRepo RepoKeyT = iota
	CKGormRepo
)

CtxKey(s)

type UserJWT

type UserJWT struct {
	jwt.StandardClaims
	UserInfo *proto.UserInfo
}

UserJWT with UserInfo

func BuildUserJWT

func BuildUserJWT(u *proto.UserInfo) *UserJWT

BuildUserJWT by userinfo

func ValidUserJWT

func ValidUserJWT(tokenStr string) (t *UserJWT, e error)

ValidUserJWT for UserInfo

func (*UserJWT) Sign

func (c *UserJWT) Sign(d time.Duration) (string, error)

Sign JWT

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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