app

package
Version: v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2018 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package boxes is a wrapper around a set of go.rice boxes created by a go.rice Config defined to first look for files in the package directory, and then in the binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assets

func Assets() *rice.Box

func CloseRedisClient added in v0.1.2

func CloseRedisClient() error

func ConnectToMySQL

func ConnectToMySQL(config *Config)

func ConnectToRedis

func ConnectToRedis(config *Config)

func GetAppConfBytes

func GetAppConfBytes() []byte

func GetLogConfBytes

func GetLogConfBytes() []byte

func GetRedisClient

func GetRedisClient() *redis.Client

func OnAppStart added in v0.1.2

func OnAppStart(f func(), order ...int)

OnAppStart registers a function to be run at app startup.

The order you register the functions will be the order they are run. You can think of it as a FIFO queue. This process will happen after the config file is read and before the server is listening for connections.

Ideally, your application should have only one call to init() in the file init.go. The reason being that the call order of multiple init() functions in the same package is undefined. Inside of init() call OnAppStart() for each function you wish to register.

This can be useful when you need to establish connections to databases or third-party services, setup app components, compile assets, or any thing you need to do between starting Server and accepting connections.

func OnAppStop added in v0.1.2

func OnAppStop(f func(), order ...int)

func Run added in v0.1.2

func Run()

Types

type Config

type Config struct {
	ServerConf struct {
		Port int `yaml:"port"`
	} `yaml:"server"`
	MySQLConf struct {
		Driver       string `yaml:"driver"`
		DataSource   string `yaml:"dataSource"`
		ShowSQL      bool   `yaml:"showSql"`
		MaxIdleConns int    `yaml:"maxIdleConns"`
		MaxOpenConns int    `yaml:"maxOpenConns"`
	} `yaml:"mysql"`
	RedisConf struct {
		Address  string `yaml:"address"`
		Password string `yaml:"password"`
	} `yaml:"redis"`
}

func LoadConfig

func LoadConfig() *Config

type JWTClaims added in v0.1.2

type JWTClaims struct {
	UserId    int64  `json:"user_id"`
	Username  string `json:"user_name"`
	Cellphone string `json:"cellphone"`
	Email     string `json:"email"`
	jwt.StandardClaims
}

func (JWTClaims) Valid added in v0.1.2

func (claims JWTClaims) Valid() error

type MySQLTemplate added in v0.1.2

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

func GetMySQLTemplate added in v0.1.2

func GetMySQLTemplate() *MySQLTemplate

func (*MySQLTemplate) Close added in v0.1.2

func (t *MySQLTemplate) Close() error

func (*MySQLTemplate) DeleteByNonEmptyFields added in v0.1.2

func (t *MySQLTemplate) DeleteByNonEmptyFields(bean interface{}) (int64, error)

Delete records from database, bean's non-empty fields will be as conditions

func (*MySQLTemplate) GetById added in v0.1.2

func (t *MySQLTemplate) GetById(id int64, bean interface{}) interface{}

Retrieve one record from database by id bean: a point of struct

Example:

GetById(1, new(models.User))

func (*MySQLTemplate) GetByNonEmptyFields added in v0.1.2

func (t *MySQLTemplate) GetByNonEmptyFields(bean interface{}) interface{}

Retrieve one record from database, bean's non-empty fields will be as conditions bean: a point of struct

func (*MySQLTemplate) Insert added in v0.1.2

func (t *MySQLTemplate) Insert(bean interface{}) (int64, error)

func (*MySQLTemplate) XormEngine added in v0.1.2

func (t *MySQLTemplate) XormEngine() *xorm.Engine

type ShutdownHook added in v0.1.2

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

type ShutdownHooks added in v0.1.2

type ShutdownHooks []ShutdownHook

func (ShutdownHooks) Len added in v0.1.2

func (slice ShutdownHooks) Len() int

func (ShutdownHooks) Less added in v0.1.2

func (slice ShutdownHooks) Less(i, j int) bool

func (ShutdownHooks) Swap added in v0.1.2

func (slice ShutdownHooks) Swap(i, j int)

type StartupHook added in v0.1.2

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

type StartupHooks added in v0.1.2

type StartupHooks []StartupHook

func (StartupHooks) Len added in v0.1.2

func (slice StartupHooks) Len() int

func (StartupHooks) Less added in v0.1.2

func (slice StartupHooks) Less(i, j int) bool

func (StartupHooks) Swap added in v0.1.2

func (slice StartupHooks) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL