restgo

package
v0.0.0-...-95a28c7 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Standard length of uniuri string to achive ~95 bits of entropy.
	StdLen = 16
	// Length of uniurl string to achive ~119 bits of entropy, closest
	// to what can be losslessly converted to UUIDv4 (122 bits).
	UUIDLen = 20
)

Variables

View Source
var StdChars = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")

Standard characters allowed in uniuri string.

Functions

func AllAuth

func AllAuth(auth ...map[string]int64) map[string]int64

将auth存储起来

func Auth

func Auth() gin.HandlerFunc

鉴权接口

func CheckVerify

func CheckVerify(ctx *gin.Context, code string) bool

func ClearAllSession

func ClearAllSession(ctx *gin.Context)

func Configuration

func Configuration(filepath string)

func Debug

func Debug(arg0 interface{}, args ...interface{})

func Error

func Error(arg0 interface{}, args ...interface{})

func Get

func Get(url string) (body string, err error)

func GetFuncMap

func GetFuncMap() template.FuncMap

func GetSession

func GetSession(ctx *gin.Context, k string) interface{}

func IsDecimals

func IsDecimals(str ...string) bool

纯小数

func IsEmail

func IsEmail(str ...string) bool

邮箱 最高30位

func IsEngishLowCase

func IsEngishLowCase(str ...string) bool

************************ 英文类型 ************************ 仅小写

func IsEnglish

func IsEnglish(str ...string) bool

大小写混合

func IsEnglishCap

func IsEnglishCap(str ...string) bool

仅大写

func IsID

func IsID(str ...string) bool

************************ 自定义类型 *********************** 数字+字母 不限制大小写 6~30位

func IsInteger

func IsInteger(str ...string) bool

************************ 数字类型 *********************** 纯整数

func IsMobile

func IsMobile(str ...string) bool

手提电话(不带前缀)最高11位

func IsPwd

func IsPwd(str ...string) bool

数字+字母+符号 6~30位

func IsTelephone

func IsTelephone(str ...string) bool

家用电话(不带前缀) 最高8位

func LoadRoleId

func LoadRoleId(ctx *gin.Context) interface{}

func LoadUser

func LoadUser(ctx *gin.Context) interface{}

func LoadVerify

func LoadVerify(ctx *gin.Context)

func Match

func Match(p string, s string) bool

func Md5encode

func Md5encode(arg0 string) string

func New

func New() string

New returns a new random string of the standard length, consisting of standard characters.

func NewLen

func NewLen(length int) string

NewLen returns a new random string of the provided length, consisting of standard characters.

func NewLenChars

func NewLenChars(length int, chars []byte) string

NewLenChars returns a new random string of the provided length, consisting of the provided byte slice of allowed characters (maximum 256).

func NoMethod

func NoMethod(ctx *gin.Context)

func NoRoute

func NoRoute(ctx *gin.Context)

Controller.go 对未定义的路由规则进行处理

func OrmEngin

func OrmEngin(keys ...string) (e *xorm.Engine)

func Post

func Post(url string, data string) (body string, err error)

func Result

func Result(ctx *gin.Context, code int, data interface{}, msg string)

func ResultFail

func ResultFail(ctx *gin.Context, err interface{})

func ResultFailData

func ResultFailData(ctx *gin.Context, data interface{}, err interface{})

func ResultList

func ResultList(ctx *gin.Context, data interface{}, total int64)

func ResultOk

func ResultOk(ctx *gin.Context, data interface{})

func ResultOkMsg

func ResultOkMsg(ctx *gin.Context, data interface{}, msg string)

func RoleAuth

func RoleAuth(roleId int, auth ...map[string]int64) map[string]int64

这个参数在RoleController初始化时处理

func SaveRoleId

func SaveRoleId(ctx *gin.Context, roleId interface{})

func SaveUser

func SaveUser(ctx *gin.Context, user interface{})

func SetCfg

func SetCfg(c *Config)

func SetEngin

func SetEngin(key string, e *xorm.Engine)

func SetSession

func SetSession(ctx *gin.Context, k string, o interface{})

Types

type Config

type Config struct {
	App         map[string]string
	Session     map[string]string
	Datasource  map[string](map[string]string)
	Static      map[string]string
	StaticFile  map[string]string
	Logger      map[string]string
	View        map[string]string
	TempFileMap map[string]int
	All         map[string]string
}

func GetCfg

func GetCfg() *Config

func (*Config) LoadBool

func (cfg *Config) LoadBool(key string) bool

获取布尔配置

func (*Config) LoadCfg

func (cfg *Config) LoadCfg(key string) string

获取整数,

func (*Config) LoadInt

func (cfg *Config) LoadInt(key string) (int, error)

获取整数,

func (*Config) LoadInt32

func (cfg *Config) LoadInt32(key string) (int64, error)

获取64位整数

func (*Config) LoadInt64

func (cfg *Config) LoadInt64(key string) (int64, error)

获取32位整数

func (*Config) LoadString

func (cfg *Config) LoadString(key string) string

获取字符串配置

func (*Config) Parse

func (cfg *Config) Parse(fpath string)

type Controller

type Controller struct {
	Data interface{}
}

func (*Controller) AjaxData

func (this *Controller) AjaxData(ctx *gin.Context)

func (*Controller) Redirect

func (this *Controller) Redirect(ctx *gin.Context, uri string)

type Image

type Image struct {
	*image.NRGBA
	// contains filtered or unexported fields
}

func NewImage

func NewImage(digits []byte, width, height int) *Image

func (*Image) WriteTo

func (img *Image) WriteTo(w io.Writer) (int64, error)

type JsonDate

type JsonDate time.Time

func (JsonDate) MarshalJSON

func (c JsonDate) MarshalJSON() ([]byte, error)

func (*JsonDate) UnmarshalJSON

func (p *JsonDate) UnmarshalJSON(data []byte) (err error)

type JsonDateTime

type JsonDateTime time.Time

func (JsonDateTime) MarshalJSON

func (c JsonDateTime) MarshalJSON() ([]byte, error)

func (JsonDateTime) String

func (c JsonDateTime) String() string

func (*JsonDateTime) UnmarshalJSON

func (p *JsonDateTime) UnmarshalJSON(data []byte) (err error)

type JsonTime

type JsonTime time.Time

func (JsonTime) MarshalJSON

func (c JsonTime) MarshalJSON() ([]byte, error)

func (JsonTime) String

func (c JsonTime) String() string

func (*JsonTime) UnmarshalJSON

func (p *JsonTime) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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