ksana

package module
v0.0.0-...-8fdc294 Latest Latest
Warning

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

Go to latest
Published: May 28, 2015 License: MIT Imports: 35 Imported by: 0

README

Ksana(A golang web framework)

Install

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) # If you are using zsh just change bash with zsh
# Restart your terminal session
gvm listall # List all Go versions available for download
gvm install go1.4.2 # Install go
gvm list
gvm use go1.4.2 --default # Using go1.4.2
go get github.com/chonglou/ksana

Orm support types

  • bool
  • string
  • float32
  • float64
  • int32
  • int64
  • []byte
  • time.Time

Examples

Files

Usage

cd examples/
go run app.go -h # show options
go run app.go -r migrate  # database migrate
go run app.go -r rollback # database rollback
go run app.go -r server   # run server
go run app.go -r routes   # show http routes
go run app.go -r db       # connect to database
go run app.go -r redis       # connect to redis
go build -ldflags "-s" app.go # build 

Documentation

Index

Constants

View Source
const VERSION = "v20150510"

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(src []byte) ([]byte, error)

func Base64Encode

func Base64Encode(src []byte) []byte

func Get

func Get(tp reflect.Type) (interface{}, bool)

func LoadLocales

func LoadLocales(path string) error

func Map

func Map(bean interface{})

func Md5

func Md5(src []byte) [16]byte

func OpenLogger

func OpenLogger(tag string) (*syslog.Writer, error)

func RandomBytes

func RandomBytes(size int) []byte

func RandomStr

func RandomStr(size int) string

func Shell

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

func T

func T(locale, key string, args ...interface{}) string

func Uuid

func Uuid() string

-----------------------------STRINGS------------------------------------------

Types

type Aes

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

func (*Aes) Decrypt

func (a *Aes) Decrypt(src, iv []byte) []byte

func (*Aes) Encrypt

func (a *Aes) Encrypt(src []byte) ([]byte, []byte)

func (*Aes) Init

func (a *Aes) Init(key []byte) error

16、24或者32位的[]byte,分别对应AES-128, AES-192或AES-256算法

type Application

type Application interface {
	Start() error
	Router() Router
	Model() Model
	Migrator() Migrator
	Mount(path string, engine Engine)
}

func New

func New() (Application, error)

type CacheManager

type CacheManager interface {
	Get(key string, value interface{}) error
	Set(key string, value interface{}, expireTime int64) error
}

type Controller

type Controller struct {
	Index   []Handler
	New     []Handler
	Create  []Handler
	Show    []Handler
	Edit    []Handler
	Update  []Handler
	Destroy []Handler
}

type Dialect

type Dialect interface {
	SERIAL() string
	UUID() string
	BOOLEAN() string
	FLOAT() string
	DOUBLE() string
	BLOB() string
	BYTES(fix bool, size int) string
	DATETIME() string

	CurDate() string
	CurTime() string
	Now() string
	Uuid() string
	Boolean(val bool) string

	CreateDatabase() string
	DropDatabase() string

	Resource() string
	Shell() (string, []string)
	Setup() string
	String() string
	Driver() string

	Select(table string, columns []string, where, order string, offset, limit int) string
}

type Engine

type Engine interface {
	Router(path string, router Router)
	Migration(Migrator, *Sql)
}

type Field

type Field struct {
	Id    string      `json:"id"`
	Flag  string      `json:"type"`
	Value interface{} `json:"value"`
	Label string      `json:"label"`
}

type Form

type Form struct {
	Id     string  `json:"id"`
	Method string  `json:"method"`
	Action string  `json:"action"`
	Token  string  `json:"token"`
	Fields []Field `json:"fields"`
}

type Handler

type Handler interface{}

type Hmac

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

func (*Hmac) Equal

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

func (*Hmac) Sum

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

type Migrator

type Migrator interface {
	Add(version, name, up, down string) error
	Migrate() error
	Rollback() error
	Generate(name string) error
}

func NewMigrator

func NewMigrator(path string, db *sql.DB, sq *Sql) (Migrator, error)

-----------------NEW-----------------------

type Model

type Model interface {
	Index(bean interface{}, unique bool, fields ...string) (string, string)
	Table(bean interface{}) (string, string, error)
	Check(path string, bean interface{}) (string, error)
}

type Redis

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

func (*Redis) Del

func (r *Redis) Del(key string) error

func (*Redis) Expire

func (r *Redis) Expire(key string, time int64) error

func (*Redis) Get

func (r *Redis) Get(key string, val interface{}) error

func (*Redis) Open

func (r *Redis) Open(cfg *redisConfig) error

func (*Redis) Set

func (r *Redis) Set(key string, val interface{}, expire int64) error

func (*Redis) Shell

func (r *Redis) Shell() (string, []string)

type RedisCacheManager

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

func (*RedisCacheManager) Get

func (p *RedisCacheManager) Get(key string, value interface{}) error

func (*RedisCacheManager) Set

func (p *RedisCacheManager) Set(key string, value interface{}, expire int64) error

type RedisSessionProvider

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

func (*RedisSessionProvider) Destroy

func (rsp *RedisSessionProvider) Destroy(sid string) error

func (*RedisSessionProvider) Init

func (rsp *RedisSessionProvider) Init(sid string) (Session, error)

func (*RedisSessionProvider) Read

func (rsp *RedisSessionProvider) Read(sid string) (Session, error)

type RedisSessionStore

type RedisSessionStore struct {
	SessionStore
	// contains filtered or unexported fields
}

func (*RedisSessionStore) Delete

func (rss *RedisSessionStore) Delete(key interface{}) error

func (*RedisSessionStore) Get

func (rss *RedisSessionStore) Get(key interface{}) interface{}

func (*RedisSessionStore) SessionId

func (rss *RedisSessionStore) SessionId() string

func (*RedisSessionStore) Set

func (rss *RedisSessionStore) Set(key, value interface{}) error

type Request

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

func (*Request) Form

func (r *Request) Form() url.Values

func (*Request) Match

func (r *Request) Match(rt Route) bool

func (*Request) Method

func (r *Request) Method() string

func (*Request) Parse

func (r *Request) Parse(rt Route)

func (*Request) Path

func (r *Request) Path() string

func (*Request) Scheme

func (r *Request) Scheme() string

type Response

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

func (*Response) Error

func (r *Response) Error(e error)

func (*Response) File

func (r *Response) File(req *http.Request, file string)

func (*Response) HtmlT

func (r *Response) HtmlT(file string, data interface{})

func (*Response) Json

func (r *Response) Json(data interface{})

func (*Response) Text

func (r *Response) Text(data []byte)

func (*Response) TextT

func (r *Response) TextT(buf *bytes.Buffer, tpl string, data interface{}) error

func (*Response) Xml

func (r *Response) Xml(data interface{})

type Route

type Route interface {
	Regex() *regexp.Regexp
	Method() string
	Pattern() string
	Status(buf *bytes.Buffer)
	Call(func(i int, h Handler) error) error
}

type Router

type Router interface {
	Get(string, ...Handler)
	Post(string, ...Handler)
	Patch(string, ...Handler)
	Put(string, ...Handler)
	Delete(string, ...Handler)
	Any(string, ...Handler)
	Resources(string, Controller)

	Status(*bytes.Buffer)
	ServeHTTP(http.ResponseWriter, *http.Request)
}

func NewRouter

func NewRouter(path string) (Router, error)

type Session

type Session interface {
	Set(key, value interface{}) error
	Get(key interface{}) interface{}
	Delete(key interface{}) error
	SessionId() string
}

type SessionManager

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

func (*SessionManager) Destroy

func (sm *SessionManager) Destroy(wrt http.ResponseWriter, req *http.Request)

func (*SessionManager) Start

func (sm *SessionManager) Start(wrt http.ResponseWriter,
	req *http.Request) (sess Session)

type SessionProvider

type SessionProvider interface {
	Init(sid string) (Session, error)
	Read(sid string) (Session, error)
	Destroy(sid string) error
}

type SessionStore

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

type Sql

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

func OpenDB

func OpenDB(cfg *dbConfig) (*sql.DB, *Sql, error)

------------------------NEW---------------------------------------------------

func (*Sql) Bool

func (p *Sql) Bool(name string, def bool) string

func (*Sql) Bytes

func (p *Sql) Bytes(name string, fix bool, size int, big, null bool) string

func (*Sql) Create

func (p *Sql) Create() string

func (*Sql) CreateIndex

func (p *Sql) CreateIndex(name, table string, unique bool, columns ...string) string

func (*Sql) CreateTable

func (p *Sql) CreateTable(table string, columns ...string) string

func (*Sql) Created

func (p *Sql) Created() string

func (*Sql) Date

func (p *Sql) Date(name string, null bool, def string) string

func (*Sql) Datetime

func (p *Sql) Datetime(name string, null bool, def string) string

func (*Sql) Delete

func (p *Sql) Delete(table, where string) string

func (*Sql) Drop

func (p *Sql) Drop() string

func (*Sql) DropIndex

func (p *Sql) DropIndex(name string) string

func (*Sql) DropTable

func (p *Sql) DropTable(table string) string

func (*Sql) Float32

func (p *Sql) Float32(name string, def float32) string

func (*Sql) Float64

func (p *Sql) Float64(name string, def float64) string

func (*Sql) Id

func (p *Sql) Id(uuid bool) string

func (*Sql) Insert

func (p *Sql) Insert(table string, columns []string) string

func (*Sql) Int32

func (p *Sql) Int32(name string, null bool, def int) string

func (*Sql) Int64

func (p *Sql) Int64(name string, null bool, def int64) string

func (*Sql) Select

func (p *Sql) Select(table string, columns []string, where, order string, offset, limit int) string

func (*Sql) Shell

func (p *Sql) Shell() (string, []string)

func (*Sql) String

func (p *Sql) String(name string, fix bool, size int, big, null bool, def string) string

func (*Sql) Time

func (p *Sql) Time(name string, null bool, def string) string

func (*Sql) Update

func (p *Sql) Update(table, columns, where string) string

func (*Sql) Updated

func (p *Sql) Updated() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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