web

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2016 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//MethodPost post method
	MethodPost = "post"
	//MethodPatch patch method
	MethodPatch = "patch"

	//TypeMarkdown markdown type
	TypeMarkdown = "markdown"
	//TypeHTML html type
	TypeHTML = "html"
)
View Source
const LOCALE = "locale"

LOCALE locale key

Variables

This section is empty.

Functions

func CfgAction

func CfgAction(f cli.ActionFunc) func(c *cli.Context) error

CfgAction config action

func FromBytes

func FromBytes(data []byte, val interface{}) error

FromBytes bytes to object

func IocAction

func IocAction(fn func(*cli.Context, *inject.Graph) error) func(c *cli.Context) error

IocAction ioc action

func IsProduction

func IsProduction() bool

IsProduction is production mode?

func JSON

func JSON(fn func(*gin.Context) (interface{}, error)) gin.HandlerFunc

JSON json response

func Loop

func Loop(fn func(en Engine) error) error

Loop loop engines

func Main

func Main(version string) error

Main entry

func OpenLogger

func OpenLogger(tag string) (*syslog.Writer, error)

OpenLogger open syslog writer

func RandomStr

func RandomStr(n int) string

RandomStr randome string

func Redirect

func Redirect(fn func(*gin.Context) (string, error)) gin.HandlerFunc

Redirect rediect response

func Register

func Register(en ...Engine)

Register register engines

func Shell

func Shell(cmd string, args ...string) error

Shell exec shell command

func ToBytes

func ToBytes(val interface{}) ([]byte, error)

ToBytes object to bytes

Types

type Aes

type Aes struct {
	Cip cipher.Block `inject:"aes.cip"`
}

Aes aes

func (*Aes) Decrypt

func (p *Aes) Decrypt(buf []byte) ([]byte, error)

Decrypt decrypt buffer

func (*Aes) Encrypt

func (p *Aes) Encrypt(buf []byte) ([]byte, error)

Encrypt encrypt buffer

type Cache

type Cache struct {
	Redis *redis.Pool `inject:"cache.redis"`
}

Cache cache

func (*Cache) Flush

func (p *Cache) Flush() error

Flush clear cache items

func (*Cache) Get

func (p *Cache) Get(key string, val interface{}) error

Get get from cache

func (*Cache) Keys

func (p *Cache) Keys() ([]string, error)

Keys list cache items

func (*Cache) Set

func (p *Cache) Set(key string, val interface{}, ttl uint) error

Set cache item

type CheckBox

type CheckBox struct {
	ID       string
	Label    string
	Readonly bool
	Options  []Option
	Helper   string
}

CheckBox checkbox

func (*CheckBox) Type

func (p *CheckBox) Type() string

Type type

type DateField

type DateField struct {
	ID       string
	Label    string
	Value    time.Time
	Readonly bool
	Helper   string
}

DateField date

func (*DateField) Type

func (p *DateField) Type() string

Type type

type Dropdown struct {
	ID    string
	Label string
	Links []Link
}

Dropdown dropdown

type EmailField

type EmailField struct {
	ID       string
	Label    string
	Value    string
	Readonly bool
	Helper   string
}

EmailField text

func (*EmailField) Type

func (p *EmailField) Type() string

Type type

type Engine

type Engine interface {
	//Home home
	Home() gin.HandlerFunc
	//Init init ioc objects
	Init(*inject.Graph) error
	//Mount web points
	Mount(*gin.Engine)
	//Shell command line
	Shell() []cli.Command
	//Worker register worker
	Worker()
}

Engine web engine

type Field

type Field interface {
	Type() string
}

Field input field

type Form

type Form struct {
	XSRF   string
	Locale string
	ID     string
	Title  string
	Action string
	Method string
	Fields []Field
}

Form form model

func (*Form) Add

func (p *Form) Add(fields ...Field)

Add add fields

type HiddenField

type HiddenField struct {
	ID    string
	Value interface{}
}

HiddenField hidden

func (*HiddenField) Type

func (p *HiddenField) Type() string

Type type

type Hmac

type Hmac struct {
	Key  []byte           `inject:"hmac.key"`
	Hash func() hash.Hash `inject:"hmac.hash"`
}

Hmac hmac

func (*Hmac) Chk

func (p *Hmac) Chk(plain, code []byte) bool

Chk check password

func (*Hmac) Sum

func (p *Hmac) Sum(plain []byte) []byte

Sum sum a password

type I18n

type I18n struct {
	Db *gorm.DB `inject:""`
}

I18n i18n

func (*I18n) Codes

func (p *I18n) Codes(lang string) []string

Codes get codes

func (*I18n) Del

func (p *I18n) Del(lang string, code string) error

Del del locale

func (*I18n) E

func (p *I18n) E(lang string, code string, args ...interface{}) error

E error

func (*I18n) Get

func (p *I18n) Get(lang string, code string) (string, error)

Get get message

func (*I18n) Handler

func (p *I18n) Handler(c *gin.Context)

Handler locale handler

func (*I18n) Languages

func (p *I18n) Languages() []string

Languages supported languages

func (*I18n) Load

func (p *I18n) Load(dir string) error

Load load locales from file

func (*I18n) Locales

func (p *I18n) Locales(lang string) map[string]interface{}

Locales list locales by lang

func (*I18n) Set

func (p *I18n) Set(lang string, code, message string) error

Set set message

func (*I18n) T

func (p *I18n) T(lang string, code string, args ...interface{}) string

T translate

type Link struct {
	Href  string
	Label string
}

Link link

type Locale

type Locale struct {
	Model

	Lang    string `json:"lang"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

Locale locale model

type Model

type Model struct {
	ID        uint      `json:"id" gorm:"primary_key"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Model basic db model

type Option

type Option struct {
	Value    interface{}
	Name     interface{}
	Selected bool
}

Option option

type PasswordField

type PasswordField struct {
	ID     string
	Label  string
	Helper string
}

PasswordField text

func (*PasswordField) Type

func (p *PasswordField) Type() string

Type type

type Radio

type Radio struct {
	ID       string
	Label    string
	Multi    bool
	Readonly bool
	Options  []Option
	Helper   string
}

Radio radio

func (*Radio) Type

func (p *Radio) Type() string

Type type

type Select

type Select struct {
	ID       string
	Label    string
	Multi    bool
	Readonly bool
	Options  []Option
	Helper   string
}

Select select

func (*Select) Type

func (p *Select) Type() string

Type type

type Ssha

type Ssha struct {
}

Ssha sha512 with salt

func (*Ssha) Chk

func (p *Ssha) Chk(plain, code string) (bool, error)

Chk check

func (*Ssha) Sum

func (p *Ssha) Sum(plain string, num uint) (string, error)

Sum sum

type TextField

type TextField struct {
	ID       string
	Label    string
	Value    string
	Readonly bool
	Helper   string
}

TextField text

func (*TextField) Type

func (p *TextField) Type() string

Type type

type Textarea

type Textarea struct {
	ID       string
	Label    string
	Value    string
	Readonly bool
	Helper   string
}

Textarea textarea

func (*Textarea) Type

func (p *Textarea) Type() string

Type type

Jump to

Keyboard shortcuts

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