config

package
v0.0.0-...-861a228 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName = "AppName"
	AppEnv  = "AppEnv"
	AppUrl  = "AppUrl"
	AppPort = "AppPort"
)
View Source
const (
	DatabaseSQL   = "DatabaseSQL"
	DatabaseCache = "DatabaseCache"
)
View Source
const (
	LogLevel              = "LogLevel"
	LogEnabled            = "LogEnabled"
	LogFile               = "LogFile"
	LogStatus             = "LogStatus"
	LogIP                 = "LogIP"
	LogMethod             = "LogMethod"
	LogPath               = "LogPath"
	LogQuery              = "LogQuery"
	LogColumns            = "LogColumns"
	LogMessageContextKeys = "LogMessageContextKeys"
	LogMessageHeaderKeys  = "LogMessageHeaderKeys"
)
View Source
const (
	StaticRequestPath = "StaticRequestPath"
	StaticAssets      = "StaticAssets"
	StaticFavicon     = "StaticFavicon"
	StaticIndexName   = "StaticIndexName"
	StaticGzip        = "StaticGzip"
	StaticShowList    = "StaticShowList"
)
View Source
const (
	Production = "production"
)

Variables

This section is empty.

Functions

func BootStrap

func BootStrap(env string, property ...Property) iris.Configurator

func Get

func Get(app context.Application, key string) interface{}

func GetBool

func GetBool(app context.Application, key string) bool

func GetInt

func GetInt(app context.Application, key string) int64

func GetString

func GetString(app context.Application, key string) string

func ReadYAML

func ReadYAML(filename string) ([]byte, error)

Types

type App

type App struct {
	AppName string `yaml:"AppName"`
	AppEnv  string `yaml:"AppEnv"`
	AppUrl  string `yaml:"AppUrl"`
	AppPort string `yaml:"AppPort"`
}

func DefaultApp

func DefaultApp() App

func GetApp

func GetApp(app context.Application) App

func (*App) Register

func (app *App) Register(others *map[string]interface{})

type Cache

type Cache struct {
	Name     string `yaml:"Name"`
	Driver   string `yaml:"Driver"`
	Host     string `yaml:"Host"`
	Port     int    `yaml:"Port"`
	Password string `yaml:"Password"`
	Db       int    `yaml:"Db"`
	Ssl      bool   `yaml:"Ssl"`
}

type Configuration

type Configuration interface {
	Register(others *map[string]interface{})
}

type Database

type Database struct {
	SQL   []SQL   `yaml:"SQL"`
	Cache []Cache `yaml:"Cache"`
}

func DefaultDatabase

func DefaultDatabase() Database

func GetDatabase

func GetDatabase(app context.Application) Database

func (*Database) Register

func (db *Database) Register(others *map[string]interface{})

type Env

type Env struct {
	Iris     iris.Configuration `yaml:"Iris"`
	App      App                `yaml:"App"`
	Static   Static             `yaml:"Static"`
	Log      Log                `yaml:"Log"`
	Database Database           `yaml:"Database"`
}

func DefaultEnv

func DefaultEnv() Env

func (*Env) Register

func (e *Env) Register(others *map[string]interface{})

type Log

type Log struct {
	Level              string   `yaml:"Level"`
	Enabled            bool     `yaml:"Enabled"`
	File               string   `yaml:"File"`
	Status             bool     `yaml:"Status"`
	IP                 bool     `yaml:"IP"`
	Method             bool     `yaml:"Method"`
	Path               bool     `yaml:"Path"`
	Query              bool     `yaml:"Query"`
	Columns            bool     `yaml:"Columns"`
	MessageContextKeys []string `yaml:"MessageContextKeys"`
	MessageHeaderKeys  []string `yaml:"MessageHeaderKeys"`
}

func DefaultLog

func DefaultLog() Log

func GetLog

func GetLog(app context.Application) Log

func (*Log) Register

func (l *Log) Register(others *map[string]interface{})

type Property

type Property func(env string) map[string]interface{}

type SQL

type SQL struct {
	Name     string `yaml:"Name"`
	Driver   string `yaml:"Driver"`
	Host     string `yaml:"Host"`
	Port     int    `yaml:"Port"`
	Dbname   string `yaml:"Dbname"`
	Username string `yaml:"Username"`
	Password string `yaml:"Password"`
	Sslmode  bool   `yaml:"Sslmode"`
	Charset  string `yaml:"Charset"`
	MaxIdle  int    `yaml:"MaxIdle"`
	MaxOpen  int    `yaml:"MaxOpen"`
	Log      bool   `yaml:"Log"`
}

type Static

type Static struct {
	RequestPath string `yaml:"RequestPath"`
	Assets      string `yaml:"Assets"`
	Favicon     string `yaml:"Favicon"`
	IndexName   string `yaml:"IndexName"`
	Gzip        bool   `yaml:"Gzip"`
	ShowList    bool   `yaml:"ShowList"`
}

func DefaultStatic

func DefaultStatic() Static

func GetStatic

func GetStatic(app context.Application) Static

func (*Static) Register

func (s *Static) Register(others *map[string]interface{})

Jump to

Keyboard shortcuts

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