web

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2017 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HTML html
	HTML = "html"
	// MARKDOWN markdown
	MARKDOWN = "markdown"
	// TEXT text
	TEXT = "text"
)
View Source
const LOCALE = "locale"

LOCALE locale context key

View Source
const (
	// PRODUCTION production mode
	PRODUCTION = "production"
)

Variables

View Source
var (
	// Version version
	Version string
	// BuildTime build time
	BuildTime string
	// Usage usage
	Usage string
	// Copyright copyright
	Copyright string
	// AuthorName author's name
	AuthorName string
	// AuthorEmail author's email
	AuthorEmail string
)

Functions

func ConfigAction

func ConfigAction(f cli.ActionFunc) cli.ActionFunc

ConfigAction read config at first

func FuncName

func FuncName(f interface{}) string

FuncName get func's name

func InjectAction

func InjectAction(f cli.ActionFunc) cli.ActionFunc

InjectAction open beans at first

func LoggerMiddleware

func LoggerMiddleware(wrt http.ResponseWriter, req *http.Request, next http.HandlerFunc)

LoggerMiddleware logger middleware

func MODE

func MODE() string

MODE run mode

func Main

func Main(args ...string) error

Main entry

func RandomBytes

func RandomBytes(l int) ([]byte, error)

RandomBytes random bytes

func Register

func Register(args ...Plugin)

Register register plugins

func SECRET

func SECRET() ([]byte, error)

SECRET secret key 32-bits

func Shell

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

Shell exec shell command

Types

type Cache

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

Cache cache

func NewCache

func NewCache(pool *redis.Pool, prefix string) *Cache

NewCache new cache

func (*Cache) Flush

func (p *Cache) Flush() error

Flush clear cache

func (*Cache) Get

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

Get get

func (*Cache) Keys

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

Keys cache keys

func (*Cache) Set

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

Set set

type Consumer

type Consumer func(id string, body []byte) error

Consumer task handler

type I18n

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

I18n i18n

func NewI18n

func NewI18n(path string, db *pg.DB) (*I18n, error)

NewI18n create i18n

func (*I18n) E

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

E error

func (*I18n) H

func (p *I18n) H(lang, code string, obj interface{}) (string, error)

H html

func (*I18n) Languages

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

Languages language tags

func (*I18n) Middleware

func (p *I18n) Middleware(tags ...language.Tag) gin.HandlerFunc

Middleware parse locales

func (*I18n) Set

func (p *I18n) Set(tx *pg.Tx, lang, code, message string) error

Set set

func (*I18n) T

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

T text

type Jobber

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

Jobber jobber

func NewJobber

func NewJobber(url, queue string) (*Jobber, error)

NewJobber new jobbber

func (*Jobber) Receive

func (p *Jobber) Receive(consumer string) error

Receive receive

func (*Jobber) Register

func (p *Jobber) Register(_type string, hnd Consumer)

Register register handler

func (*Jobber) Send

func (p *Jobber) Send(_type string, priority uint8, body interface{}) error

Send send job

func (*Jobber) Status

func (p *Jobber) Status() map[string]interface{}

Status status

type Jwt

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

Jwt jwt

func NewJwt

func NewJwt(key []byte, method crypto.SigningMethod) *Jwt

NewJwt new jwt

func (*Jwt) Parse

func (p *Jwt) Parse(r *http.Request) (jwt.Claims, error)

Parse parse

func (*Jwt) Sum

func (p *Jwt) Sum(cm jws.Claims, exp time.Duration) ([]byte, error)

Sum create jwt token

func (*Jwt) Validate

func (p *Jwt) Validate(buf []byte) (jwt.Claims, error)

Validate check jwt

type Locale

type Locale struct {
	ID        uint      `json:"id"`
	Lang      string    `json:"lang"`
	Code      string    `json:"code"`
	Message   string    `json:"message"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

Locale locale

type Plugin

type Plugin interface {
	// init beans
	Init(*inject.Graph) error
	// console commands
	Shell() []cli.Command
	// register
	Mount() error
}

Plugin plugin

type S3

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

S3 amazon s3

func NewS3

func NewS3(accessKeyID, secretAccessKey, region, bucket string) (*S3, error)

NewS3 new s3

func (*S3) Write

func (p *S3) Write(name string, body []byte, size int64) (string, string, error)

Write write to

type Security

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

Security security helper

func NewSecurity

func NewSecurity(key []byte) (*Security, error)

NewSecurity new security

func (*Security) Check

func (p *Security) Check(encode, plain []byte) bool

Check check hash

func (*Security) Decrypt

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

Decrypt decrypt

func (*Security) Encrypt

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

Encrypt encrypt

func (*Security) Hash

func (p *Security) Hash(plain []byte) ([]byte, error)

Hash ont-way encrypt

type Setting

type Setting struct {
	ID        uint
	Key       string
	Value     []byte
	Encode    bool `sql:",notnull"`
	UpdatedAt time.Time
	CreatedAt time.Time
	// contains filtered or unexported fields
}

Setting setting model

type Settings

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

Settings settings

func NewSettings

func NewSettings(db *pg.DB, sec *Security) *Settings

NewSettings new settings

func (*Settings) Get

func (p *Settings) Get(key string, obj interface{}) error

Get get

func (*Settings) Set

func (p *Settings) Set(tx *pg.Tx, key string, obj interface{}, encode bool) error

Set set

type UEditor

type UEditor struct {
}

UEditor ueditor

func (*UEditor) Upload

func (p *UEditor) Upload(wrt UEditorWriter, images UEditorManager, files UEditorManager) gin.HandlerFunc

Upload upload handler

type UEditorManager

type UEditorManager func(c *gin.Context) (urls []string, err error)

UEditorManager ueditor's file manager

type UEditorWriter

type UEditorWriter func(c *gin.Context, name string, buf []byte, size int64) (url string, err error)

UEditorWriter ueditor's file writer

Jump to

Keyboard shortcuts

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