web

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2018 License: MIT Imports: 45 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// TypeHTML html
	TypeHTML = "html"
	// TypeMARKDOWN markdown
	TypeMARKDOWN = "markdown"
	// TypeTEXT text
	TypeTEXT = "text"
	// DateFormat date format
	DateFormat = "2006-01-02"
)
View Source
const (
	// LOCALE locale key
	LOCALE = "locale"
)
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 {
	Pool *redis.Pool `inject:""`
	// contains filtered or unexported fields
}

Cache cache

func NewCache

func NewCache(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 {
	DB        *gorm.DB `inject:""`
	Cache     *Cache   `inject:""`
	Languages []string `inject:"languages"`
}

I18n i18n

func (*I18n) All

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

All list items by lang

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

func (p *I18n) Middleware() (gin.HandlerFunc, error)

Middleware locale middleware

func (*I18n) Set

func (p *I18n) Set(db *gorm.DB, lang, code, message string) error

Set set

func (*I18n) Sync

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

Sync sync from filesystem to database

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" gorm:"primary_key"`
	Lang      string    `json:"lang"`
	Code      string    `json:"code"`
	Message   string    `json:"message"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
}

Locale locale

func (Locale) TableName

func (p Locale) TableName() string

TableName table name

type Plugin

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

Plugin plugin

type RSS

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

RSS rss helper

func NewRSS

func NewRSS() *RSS

NewRSS new RSS

func (*RSS) Register

func (p *RSS) Register(handlers ...RSSHandler)

Register register handler

func (*RSS) ToAtom

func (p *RSS) ToAtom(host, lang, title, dest string, author *feeds.Author, wrt io.Writer) error

ToAtom write to atom

type RSSHandler

type RSSHandler func(l string) ([]*feeds.Item, error)

RSSHandler rss handler

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 `gorm:"primary_key"`
	Key       string
	Value     []byte
	Encode    bool
	UpdatedAt time.Time
	CreatedAt time.Time
}

Setting setting model

func (Setting) TableName

func (p Setting) TableName() string

TableName table name

type Settings

type Settings struct {
	Security *Security `inject:""`
}

Settings settings

func (*Settings) Get

func (p *Settings) Get(db *gorm.DB, key string, obj interface{}) error

Get get

func (*Settings) Set

func (p *Settings) Set(db *gorm.DB, key string, obj interface{}, encode bool) error

Set set

type Sitemap

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

Sitemap sitemap helper

func NewSitemap

func NewSitemap() *Sitemap

NewSitemap new sitemap

func (*Sitemap) Register

func (p *Sitemap) Register(handlers ...SitemapHandler)

Register register handler

func (*Sitemap) ToXMLGz

func (p *Sitemap) ToXMLGz(h string, w io.Writer) error

ToXMLGz write xml.gz

type SitemapHandler

type SitemapHandler func() ([]stm.URL, error)

SitemapHandler sitemap handler

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