components

package
v0.0.0-...-1bf86c4 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	All        = `*`
	True       = `true`
	Dot        = ","
	Nil        = ""
	HeaderHost = "Host"
	LocalHost  = "localhost"
	// 跨域 头部
	HeaderAllowedOriginsKey   = "AllowedOrigins"
	HeaderAllowedHeadersKey   = "AllowedHeaders"
	HeaderAllowedMethodsKey   = "AllowedMethods"
	HeaderAllowCredentialsKey = "AllowCredentials"
	// 跨域 默认值
	DefaultAllowOrigins     = All
	DefaultAllowCredentials = True
	DefaultAllowHeaders     = All
	DefaultAllMethods       = `HEAD, GET, POST, PUT, PATCH, DELETE`
	// 跨域 可配置 key
	CrossDomainAllowedIpConfKey        = "system.http.crossDomain.allowedIp"
	CrossDomainAllowedOriginsConfKey   = "system.http.crossDomain.allowedOrigins"
	CrossDomainAllowedHeadersConfKey   = "system.http.crossDomain.allowedHeaders"
	CrossDomainAllowedMethodsConfKey   = "system.http.crossDomain.allowedMethods"
	CrossDomainAllowCredentialsConfKey = "system.http.crossDomain.allowCredentials"
	// 自定义的处理器
	CrossDomainAllowedIpFilterIdConfKey      = "system.http.crossDomain.allowedIpFilter"
	CrossDomainAllowedOriginsFilterIdConfKey = "system.http.crossDomain.allowedOriginsFilter"
	CrossDomainAllowedMethodsFilterIdConfKey = "system.http.crossDomain.allowedMethodsFilter"
	CrossDomainAllowedHeadersFilterIdConfKey = "system.http.crossDomain.allowedHeadersFilter"
)
View Source
const (
	ServerNameKey              = "server"
	ServerVersionKey           = "server-version"
	DefSystemServerVersion     = "1.0.0"
	DefSystemServerHost        = "golang-iris"
	SystemServerHostConfKey    = "system.server.host"
	SystemServerVersionConfKey = "system.server.version"
)
View Source
const RedisConfPrefixKey = "redis"
View Source
const RedisDefaultConnKey = "redis.default"
View Source
const RedisDefaultTcpNetWork = "tcp"
View Source
const RedisNetWorkConfKey = "network"

Variables

View Source
var NilPassByte = ByteToPassword([]byte(""))
View Source
var NilPassStr = StrToPassword("")

Functions

func AddSupportEnvs

func AddSupportEnvs(env EnvType, name string) bool

追加自定义环境变量

func Auth

func Auth()
func BuilderRedisConnectionLink(properties RedisProperties) string

func CreateRedisClient

func CreateRedisClient(name string) Base.IRedisClient

func CreateToken

func CreateToken(data Jwt.Claims, signKeys ...string) string

func CreateTokenDataMap

func CreateTokenDataMap(data map[string]interface{}, Standards ...Jwt.StandardClaims) Jwt.Claims

func CrossDomain

func CrossDomain(ctx iris.Context)

跨域中间件

func DecodeToken

func DecodeToken(t string, v interface{}, signKey ...string) bool

func EqualPassword

func EqualPassword(userPassword string, hashed string) bool

密码比对

func GetSupportEnvMap

func GetSupportEnvMap() map[string]string

获取 支持的 环境表 Map

func IsInSupport

func IsInSupport(env EnvType) bool

是否在支持的环境表中

func NewConfigure

func NewConfigure(instance ...kvs.ConfigSource) Base.IConfiguration

func NewCustomError

func NewCustomError(msg string, code int, tyName string, parent ...error) Base.ErrorInstance

func NewError

func NewError(code int, msg string, parent ...error) Base.ErrorInstance

func RedisDial

func RedisDial(properties RedisProperties) (redis.Conn, error)

func ServerHttpHeader

func ServerHttpHeader(ctx iris.Context)

Types

type ConfigureWrapper

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

func (*ConfigureWrapper) Create

func (c *ConfigureWrapper) Create() interface{}

func (*ConfigureWrapper) Durations

func (c *ConfigureWrapper) Durations(key string) []time.Duration

func (*ConfigureWrapper) Float64s

func (c *ConfigureWrapper) Float64s(key string) []float64

func (*ConfigureWrapper) Get

func (c *ConfigureWrapper) Get(key string) (string, error)

func (*ConfigureWrapper) GetBool

func (c *ConfigureWrapper) GetBool(key string) (bool, error)

func (*ConfigureWrapper) GetBoolDefault

func (c *ConfigureWrapper) GetBoolDefault(key string, defaultValue bool) bool

func (*ConfigureWrapper) GetDefault

func (c *ConfigureWrapper) GetDefault(key string, defaultValue string) string

func (*ConfigureWrapper) GetDuration

func (c *ConfigureWrapper) GetDuration(key string) (time.Duration, error)

func (*ConfigureWrapper) GetDurationDefault

func (c *ConfigureWrapper) GetDurationDefault(key string, defaultValue time.Duration) time.Duration

func (*ConfigureWrapper) GetFloat64

func (c *ConfigureWrapper) GetFloat64(key string) (float64, error)

func (*ConfigureWrapper) GetFloat64Default

func (c *ConfigureWrapper) GetFloat64Default(key string, defaultValue float64) float64

func (*ConfigureWrapper) GetInt

func (c *ConfigureWrapper) GetInt(key string) (int, error)

func (*ConfigureWrapper) GetIntDefault

func (c *ConfigureWrapper) GetIntDefault(key string, defaultValue int) int

func (*ConfigureWrapper) Ints

func (c *ConfigureWrapper) Ints(key string) []int

func (*ConfigureWrapper) Keys

func (c *ConfigureWrapper) Keys() []string

func (*ConfigureWrapper) Prefix

func (c *ConfigureWrapper) Prefix(prefix string, withOutPrefix ...bool) Base.ConfigureFace

func (*ConfigureWrapper) Set

func (c *ConfigureWrapper) Set(key string, value string)

func (*ConfigureWrapper) SetAll

func (c *ConfigureWrapper) SetAll(data map[string]string)

func (*ConfigureWrapper) Strings

func (c *ConfigureWrapper) Strings(key string) []string

func (*ConfigureWrapper) Unmarshal

func (c *ConfigureWrapper) Unmarshal(t interface{}) error

type CustomError

type CustomError struct {
	ErrType string
	Parent  error
	// contains filtered or unexported fields
}

自定义

func (*CustomError) Code

func (c *CustomError) Code() int

func (*CustomError) Error

func (c *CustomError) Error() string

func (*CustomError) ErrorType

func (c *CustomError) ErrorType() string

func (*CustomError) Message

func (c *CustomError) Message() string

func (*CustomError) New

func (c *CustomError) New(msg string, code int, parent ...error) error

func (*CustomError) Set

func (c *CustomError) Set(key string, value interface{}) Base.ErrorInstance

func (*CustomError) TraceString

func (c *CustomError) TraceString() string

func (*CustomError) Traces

func (c *CustomError) Traces() []string

type EnvType

type EnvType string

环境变量类型

const (
	EnvDev     EnvType = "dev"
	EnvProd    EnvType = "prod"
	EnvLocal   EnvType = "local"
	EnvTest    EnvType = "test"
	EnvStage   EnvType = "stage"
	EnvGrey    EnvType = "grey"
	EnvUnknown EnvType = "" // 未支持类型
)

func EnvMeanStrToEnv

func EnvMeanStrToEnv(m string) (EnvType, bool)

环境 提示 语 转环境操作对象

func GetSupportEnvs

func GetSupportEnvs() (envs []EnvType)

获取 注册表中所有支持环境

func StrToEnvType

func StrToEnvType(e string) (env EnvType, ok bool)

环境字符串转 环境操作对象

func StrToEnvTypeDefault

func StrToEnvTypeDefault(e string, def EnvType) EnvType

字符串转环境对象

func (EnvType) Equal

func (e EnvType) Equal(e2 EnvType) bool

func (EnvType) GetMean

func (e EnvType) GetMean() string

获取环境含义提示语 (中文表示)

func (EnvType) IsIn

func (e EnvType) IsIn(envs []EnvType) bool

func (EnvType) ToJson

func (e EnvType) ToJson() string

func (EnvType) ToMap

func (e EnvType) ToMap() (data map[string]string)

func (EnvType) ToString

func (e EnvType) ToString() string

type IDataModel

type IDataModel interface {
	Connection(name ...string) starters.IDataBaseConnector
}

type OriginDomainFilterHandler

type OriginDomainFilterHandler func(string) (string, bool)

type OriginDomainHandler

type OriginDomainHandler func(string) ([]string, bool)

跨域来源 处理器

type PasswordByte

type PasswordByte []byte

func ByteToPassword

func ByteToPassword(by []byte) PasswordByte

func Password

func Password(userPassword string, cost ...int) (PasswordByte, bool)

GeneratePassword 给密码就行加密操作

func (PasswordByte) Equal

func (b PasswordByte) Equal(stPass PasswordByte) bool

func (PasswordByte) Equals

func (b PasswordByte) Equals(stPass string) bool

func (PasswordByte) New

func (b PasswordByte) New(pass []byte, cost ...int) (PasswordByte, bool)

func (PasswordByte) ToPasswordStr

func (b PasswordByte) ToPasswordStr() PasswordStr

func (PasswordByte) ToString

func (b PasswordByte) ToString() string

type PasswordStr

type PasswordStr string

func StrToPassword

func StrToPassword(str string) PasswordStr

func (PasswordStr) Equal

func (str PasswordStr) Equal(stPass PasswordStr) bool

func (PasswordStr) Equals

func (str PasswordStr) Equals(stPass string) bool

func (PasswordStr) New

func (str PasswordStr) New(pass string, cost ...int) (PasswordStr, bool)

func (PasswordStr) ToByte

func (str PasswordStr) ToByte() []byte

func (PasswordStr) ToPasswordByte

func (str PasswordStr) ToPasswordByte() PasswordByte

func (PasswordStr) ToString

func (str PasswordStr) ToString() string

type RedisClient

type RedisClient struct {
	Properties RedisProperties
	// contains filtered or unexported fields
}

func NewRedisClient

func NewRedisClient(conn redis.Conn, properties RedisProperties) *RedisClient

func (*RedisClient) Close

func (client *RedisClient) Close()

func (*RedisClient) Command

func (client *RedisClient) Command(command string, args ...interface{}) (interface{}, error)

func (*RedisClient) Del

func (client *RedisClient) Del(key string)

func (*RedisClient) Exists

func (client *RedisClient) Exists(key string) bool

func (*RedisClient) Get

func (client *RedisClient) Get(key string) (string, error)

func (*RedisClient) GetConn

func (client *RedisClient) GetConn() redis.Conn

func (*RedisClient) GetInt

func (client *RedisClient) GetInt(key string) (int, error)

func (*RedisClient) HGet

func (client *RedisClient) HGet(key string, field string) (string, error)

func (*RedisClient) HGetAll

func (client *RedisClient) HGetAll(key string) (map[string]string, error)

func (*RedisClient) HSet

func (client *RedisClient) HSet(key string, hash map[string]string)

func (*RedisClient) Set

func (client *RedisClient) Set(key string, value string)

func (*RedisClient) SetConn

func (client *RedisClient) SetConn(conn redis.Conn) *RedisClient

func (*RedisClient) Setex

func (client *RedisClient) Setex(key string, value string, expire time.Duration)

type RedisProperties

type RedisProperties interface {
	GetAddr() net.Addr
	GetTlsOn() bool
	SetTlsOn(bool) RedisProperties
	GetTlsConf() *tls.Config
	SetTlsConf(config *tls.Config) RedisProperties
	GetDataBase() int
	UseDataBase(number int) RedisProperties
	GetDialer() *net.Dialer
	SetDialer(dialer *net.Dialer) RedisProperties
	SetReadTimeOut(rd time.Duration) RedisProperties
	GetReadTimeOut() time.Duration
	SetWriteTimeOut(wd time.Duration) RedisProperties
	GetWriteTimeOut() time.Duration
	GetPassword() string
	SetPassword(string) RedisProperties
	GetSkipVerify() bool
	SetSkipVerify(bool) RedisProperties
	GetDial() func(network, addr string) (net.Conn, error)
	SetAddr(network string, addr string, port ...int) RedisProperties
	Options() []redis.DialOption
	SetDial(handler func(network, addr string) (net.Conn, error)) RedisProperties
}

func BuilderRedisProperties

func BuilderRedisProperties(conf Base.IConfiguration) RedisProperties

type RedisProps

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

func (*RedisProps) GetAddr

func (props *RedisProps) GetAddr() net.Addr

func (*RedisProps) GetDataBase

func (props *RedisProps) GetDataBase() int

func (*RedisProps) GetDial

func (props *RedisProps) GetDial() func(network, addr string) (net.Conn, error)

func (*RedisProps) GetDialer

func (props *RedisProps) GetDialer() *net.Dialer

func (*RedisProps) GetPassword

func (props *RedisProps) GetPassword() string

func (*RedisProps) GetReadTimeOut

func (props *RedisProps) GetReadTimeOut() time.Duration

func (*RedisProps) GetSkipVerify

func (props *RedisProps) GetSkipVerify() bool

func (*RedisProps) GetTlsConf

func (props *RedisProps) GetTlsConf() *tls.Config

func (*RedisProps) GetTlsOn

func (props *RedisProps) GetTlsOn() bool

func (*RedisProps) GetWriteTimeOut

func (props *RedisProps) GetWriteTimeOut() time.Duration

func (*RedisProps) Options

func (props *RedisProps) Options() []redis.DialOption

func (*RedisProps) SetAddr

func (props *RedisProps) SetAddr(network string, addr string, port ...int) RedisProperties

func (*RedisProps) SetDial

func (props *RedisProps) SetDial(handler func(network, addr string) (net.Conn, error)) RedisProperties

func (*RedisProps) SetDialer

func (props *RedisProps) SetDialer(dialer *net.Dialer) RedisProperties

func (*RedisProps) SetPassword

func (props *RedisProps) SetPassword(pass string) RedisProperties

func (*RedisProps) SetReadTimeOut

func (props *RedisProps) SetReadTimeOut(rd time.Duration) RedisProperties

func (*RedisProps) SetSkipVerify

func (props *RedisProps) SetSkipVerify(on bool) RedisProperties

func (*RedisProps) SetTlsConf

func (props *RedisProps) SetTlsConf(config *tls.Config) RedisProperties

func (*RedisProps) SetTlsOn

func (props *RedisProps) SetTlsOn(on bool) RedisProperties

func (*RedisProps) SetWriteTimeOut

func (props *RedisProps) SetWriteTimeOut(wd time.Duration) RedisProperties

func (*RedisProps) UseDataBase

func (props *RedisProps) UseDataBase(number int) RedisProperties

Jump to

Keyboard shortcuts

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