core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2016 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const JSON = "application/json; charset=UTF-8"
View Source
const PLAIN = "text/plain; charset=UTF-8"
View Source
const XML = "application/xml; charset=UTF-8"

Variables

View Source
var ENV = cli.StringFlag{
	Name:   "environment, e",
	Value:  "development",
	Usage:  "Specifies the environment to run this server under (test/development/production).",
	EnvVar: "ITPKG_ENV",
}

Functions

func AppendSalt

func AppendSalt(src, salt []byte) []byte

func Check

func Check() error

func Csha512

func Csha512(d string, p []byte) (bool, error)

func EnvAction

func EnvAction(act func(env string, c *cli.Context) error) func(c *cli.Context)

func Equal

func Equal(src []byte, dst []byte) bool

func FromBase64

func FromBase64(s string) ([]byte, error)

func FromBits

func FromBits(data []byte, obj interface{}) error

func FromHex

func FromHex(s string) ([]byte, error)

func FromJson

func FromJson(j []byte, o interface{}) error

func FromToml

func FromToml(f string, v interface{}) error

func FuncName

func FuncName(f interface{}) string

func Get

func Get(name string) interface{}

func In

func In(objects ...interface{}) error

func Loop

func Loop(fn func(Engine) error) error

func Md2Hm

func Md2Hm(md []byte) ([]byte, error)

func Md5

func Md5(p []byte) string

func Mkdirs

func Mkdirs(d string, m os.FileMode) error

func NewAesCipher

func NewAesCipher(key []byte) (cipher.Block, error)

==============================================================================

func NewHmacHash

func NewHmacHash() func() hash.Hash

=========================================================================

func ParseSalt

func ParseSalt(src []byte, length int) ([]byte, []byte)

func PkgRoot

func PkgRoot(o interface{}) string

func RandomBytes

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

func Register

func Register(ens ...Engine)

func Run

func Run() error

func Sha512

func Sha512(p []byte) string

func Shell

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

func Ssha512

func Ssha512(p []byte, l int) (string, error)

func ToBase64

func ToBase64(b []byte) string

func ToBits

func ToBits(obj interface{}) ([]byte, error)

func ToHex

func ToHex(bs []byte) string

func ToJson

func ToJson(o interface{}) ([]byte, error)

func ToToml

func ToToml(f string, v interface{}) error

func Use

func Use(objects map[string]interface{}) error

func Uuid

func Uuid() string

Types

type Aes

type Aes struct {
	//16、24或者32位的[]byte,分别对应AES-128, AES-192或AES-256算法
	Cip cipher.Block `inject:"aes.cipher"`
}

func (*Aes) Decrypt

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

func (*Aes) Encrypt

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

type Controller

type Controller struct {
}

func (*Controller) Abort

func (p *Controller) Abort(w http.ResponseWriter, e error)

func (*Controller) Forbidden

func (p *Controller) Forbidden(w http.ResponseWriter)

func (*Controller) Html

func (p *Controller) Html(w http.ResponseWriter, body string)

func (*Controller) Locale

func (p *Controller) Locale(r *http.Request) string

func (*Controller) NotFound

func (p *Controller) NotFound(w http.ResponseWriter)

func (*Controller) Pager

func (p *Controller) Pager(r *render.Render, w http.ResponseWriter, pg *Pager, i interface{})

type Engine

type Engine interface {
	Asserts() []*Template
	Mount(Router)
	Seed() error
	Migrate()
	Sitemap() sitemap.Handler
	Rss() rss.Handler
	Shell() []cli.Command
}

type Hmac

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

func (*Hmac) Equal

func (p *Hmac) Equal(src, dst []byte) bool

func (*Hmac) Sum

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

type Model

type Model struct {
	ID        uint      `gorm:"primary_key" json:"id"`
	CreatedAt time.Time `sql:"not null;default:current_timestamp" json:"created_at"`
	UpdatedAt time.Time `sql:"not null" json:"updated_at"`
}

type Pager

type Pager struct {
	Size  int `json:"size"`
	Total int `json:"total"`
	Count int `json:"count"`
	Page  int `json:"page"`
}

func NewPager

func NewPager(max int) *Pager

func (*Pager) Parse

func (p *Pager) Parse(r *http.Request) (int, int, int)

func (*Pager) SetTotal

func (p *Pager) SetTotal(total int) int

func (*Pager) To

func (p *Pager) To() map[string]int

type Router

type Router interface {
	GET(string, httprouter.Handle)
	POST(string, httprouter.Handle)
	DELETE(string, httprouter.Handle)
	PUT(string, httprouter.Handle)
	PATCH(string, httprouter.Handle)
	ServeFiles(string, http.FileSystem)
}

type Template

type Template struct {
	Lang    string
	Tpl     string
	Htm     string
	Payload interface{}
}

Jump to

Keyboard shortcuts

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