web

package
Version: v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2016 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OK = gin.H{"ok": true}

OK success return

Functions

func Action

func Action(f cli.ActionFunc) cli.ActionFunc

Action cfg action

func Bytes added in v0.0.2

func Bytes(name string, buf []byte) gin.HandlerFunc

Bytes file render

func Host

func Host() string

Host hostname

func IocAction

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

IocAction ioc action

func IsProduction

func IsProduction() bool

IsProduction production mode ?

func Logger

func Logger() *logging.Logger

Logger open logger

func Loop

func Loop(fn func(Engine) error) error

Loop loop engines

func OpenDatabase

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

OpenDatabase open database

func OpenRedis

func OpenRedis() *redis.Pool

OpenRedis open redis

func RandomStr

func RandomStr(n int) string

RandomStr random string

func Register

func Register(ens ...Engine)

Register register engine

func Rest

func Rest(h HandlerFunc) gin.HandlerFunc

Rest rest handle

func Run

func Run() error

Run main entry

Types

type Cache

type Cache struct {
	Redis  *redis.Pool     `inject:""`
	Logger *logging.Logger `inject:""`
	Prefix string          `inject:"cache.prefix"`
}

Cache cache model

func (*Cache) Flush

func (p *Cache) Flush() error

Flush clear cache

func (*Cache) Keys

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

Keys cache items

func (*Cache) Page

func (p *Cache) Page(exp time.Duration, fn gin.HandlerFunc) gin.HandlerFunc

Page cache page(by url and locale)

type CacheResponse

type CacheResponse struct {
	Status int
	//Header http.Header
	Type string
	Data []byte
}

CacheResponse page cache item

type Engine

type Engine interface {
	Map(*inject.Graph) error
	Mount(*gin.Engine)
	Migrate(*gorm.DB)
	Seed()
	Worker()
	Shell() []cli.Command
}

Engine web engine

type HandlerFunc

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

HandlerFunc rest handler

type Link struct {
	Href  string `json:"href"`
	Label string `json:"label"`
}

Link link model

type Model

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

Model base model

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL