web

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeMARKDOWN markdown format
	TypeMARKDOWN = "markdown"
	// TypeHTML html format
	TypeHTML = "html"
)
View Source
const (
	// FormatDateInput  format for date input
	FormatDateInput = "2006-01-02"
)
View Source
const (
	// LOCALE locale key
	LOCALE = "locale"
)

Variables

View Source
var (
	// Version version
	Version string
	// BuildTime build time
	BuildTime string
)

Functions

func Action

func Action(f cli.ActionFunc) cli.ActionFunc

Action cfg action

func DataSource

func DataSource() string

DataSource database source url

func IsProduction

func IsProduction() bool

IsProduction production mode ?

func JSON added in v0.3.0

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

JSON json render

func Main

func Main() error

Main main entry

func OpenDatabase

func OpenDatabase() (*gorm.DB, error)

OpenDatabase open database

func OpenRedis

func OpenRedis() *redis.Pool

OpenRedis get redis connection pool

func RandomStr

func RandomStr(n int) string

RandomStr randome string

func Register

func Register(ens ...Engine)

Register register engines

func Shell

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

Shell exec shell command

func Walk

func Walk(fn func(Engine) error) error

Walk walk engines

Types

type Cache

type Cache struct {
	Redis     *redis.Pool `inject:""`
	Namespace string      `inject:"namespace"`
}

Cache cache by redis

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) GetBytes

func (p *Cache) GetBytes(key string) ([]byte, error)

GetBytes get bytes

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 time.Duration) error

Set cache item

func (*Cache) SetBytes

func (p *Cache) SetBytes(key string, val []byte, ttl time.Duration) error

SetBytes set bytes

type Engine

type Engine interface {
	Mount(*gin.Engine)
	Shell() []cli.Command
	RegisterWorker()
	Atom(lang string) ([]*atom.Entry, error)
	Sitemap() ([]stm.URL, error)
}

Engine engine

type FileSystemUploader added in v0.3.1

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

FileSystemUploader file-system storage

func (*FileSystemUploader) Remove added in v0.3.1

func (p *FileSystemUploader) Remove(url string) error

Remove remove file

func (*FileSystemUploader) Save added in v0.3.1

Save save file to file-system

type I18n

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

I18n i18n helper

func (*I18n) Codes

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

Codes list locale keys

func (*I18n) Del

func (p *I18n) Del(lng, code string)

Del del locale

func (*I18n) E

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

E create an i18n error

func (*I18n) F

func (p *I18n) F(lng, code string, obj interface{}) (string, error)

F format message

func (*I18n) Items

func (p *I18n) Items(lng string) (map[string]interface{}, error)

Items list all items

func (*I18n) Middleware

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

Middleware locale-middleware

func (*I18n) Set

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

Set set locale

func (*I18n) Sync

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

Sync sync records

func (*I18n) T

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

T translate by lang tag

type Locale

type Locale struct {
	Model

	Lang    string `gorm:"not null;type:varchar(8);index" json:"lang"`
	Code    string `gorm:"not null;index;type:VARCHAR(255)" json:"code"`
	Message string `gorm:"not null;type:varchar(800)" json:"message"`
}

Locale locale model

func (Locale) TableName

func (Locale) TableName() string

TableName table name

type Model

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

Model base model

type Pagination

type Pagination struct {
	Page  int64         `json:"page"`
	Size  int64         `json:"size"`
	Total int64         `json:"total"`
	Count int64         `json:"count"`
	Items []interface{} `json:"items"`
}

Pagination pagination

func NewPagination

func NewPagination(r *http.Request, total int64) *Pagination

NewPagination new pagination

func (*Pagination) Limit

func (p *Pagination) Limit() int64

Limit limit

func (*Pagination) Offset

func (p *Pagination) Offset() int64

Offset offset

type Queue added in v1.0.0

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

Queue message queue

func NewQueue added in v1.0.0

func NewQueue() *Queue

NewQueue new queue

func (*Queue) Do added in v1.0.0

func (p *Queue) Do(name string) error

Do do job

func (*Queue) Register added in v1.0.0

func (p *Queue) Register(n string, f func([]byte) error)

Register register job

func (*Queue) Send added in v1.0.0

func (p *Queue) Send(exchange, queue string, body interface{})

Send send job

func (*Queue) Status added in v1.0.0

func (p *Queue) Status() map[string]string

Status status

type Security

type Security struct {
	Cip cipher.Block `inject:"aes.cip"`
	Key []byte       `inject:"hmac.key"`
}

Security security tools

func (*Security) Chk

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

Chk chk hmac

func (*Security) Decrypt

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

Decrypt aes decrypt

func (*Security) Encrypt

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

Encrypt aes encrypt

func (*Security) Sum

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

Sum sum hmac

type Setting

type Setting struct {
	Model

	Key    string `gorm:"not null;unique_index;type:VARCHAR(255)"`
	Val    []byte `gorm:"not null"`
	Encode bool   `gorm:"not null"`
}

Setting setting

func (Setting) TableName

func (Setting) TableName() string

TableName table name

type Settings

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

Settings setting helper

func (*Settings) Get

func (p *Settings) Get(k string, v interface{}) error

Get get setting value by key

func (*Settings) Set

func (p *Settings) Set(k string, v interface{}, f bool) error

Set save setting

type Uploader added in v0.3.1

type Uploader interface {
	Save(multipart.File, *multipart.FileHeader) (string, int64, error)
	Remove(string) error
}

Uploader attachment uploader

func NewFileSystemUploader added in v0.3.1

func NewFileSystemUploader(root, home string) (Uploader, error)

NewFileSystemUploader new file-system uploader

Jump to

Keyboard shortcuts

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