Documentation ¶
Index ¶
- func RunAction(actionPtr interface{}, spec *ActionSpec, request *http.Request, ...) interface{}
- type Action
- type ActionContext
- func (this *ActionContext) Get(key string) interface{}
- func (this *ActionContext) GetBool(key string) bool
- func (this *ActionContext) GetInt(key string) int
- func (this *ActionContext) GetInt64(key string) int64
- func (this *ActionContext) GetString(key string) string
- func (this *ActionContext) Set(key string, value interface{})
- type ActionObject
- func (this *ActionObject) AddCookie(cookie *http.Cookie)
- func (this *ActionObject) AddHeader(name, value string)
- func (this *ActionObject) Cache() *caches.Factory
- func (this *ActionObject) Error(error string, code int)
- func (this *ActionObject) Fail(message ...string)
- func (this *ActionObject) FailField(field string, message ...string)
- func (this *ActionObject) File(field string) *File
- func (this *ActionObject) HasParam(name string) bool
- func (this *ActionObject) HasPrefix(prefix ...string) bool
- func (this *ActionObject) Header(name string) string
- func (this *ActionObject) Next(nextAction string, params map[string]interface{}, hash ...string) *ActionObject
- func (this *ActionObject) Object() *ActionObject
- func (this *ActionObject) Param(name string) (value string, found bool)
- func (this *ActionObject) ParamArray(name string) []string
- func (this *ActionObject) ParamInt(name string) int
- func (this *ActionObject) ParamInt64(name string) int64
- func (this *ActionObject) ParamString(name string) string
- func (this *ActionObject) Pretty() *ActionObject
- func (this *ActionObject) RedirectURL(url string)
- func (this *ActionObject) Refresh() *ActionObject
- func (this *ActionObject) RequestRemoteAddr() string
- func (this *ActionObject) RequestRemoteIP() string
- func (this *ActionObject) Session() *Session
- func (this *ActionObject) SetMaxSize(maxSize float64)
- func (this *ActionObject) SetParam(name, value string)
- func (this *ActionObject) SetSessionCookieName(cookieName string)
- func (this *ActionObject) SetSessionManager(sessionManager interface{})
- func (this *ActionObject) Show()
- func (this *ActionObject) Success(message ...string)
- func (this *ActionObject) TemplateFilter(filter func(body []byte) []byte)
- func (this *ActionObject) View(viewTemplate string)
- func (this *ActionObject) ViewDir(viewDir string)
- func (this *ActionObject) ViewFunc(name string, f interface{})
- func (this *ActionObject) Write(bytes []byte) (n int, err error)
- func (this *ActionObject) WriteFormat(format string, args ...interface{}) (n int, err error)
- func (this *ActionObject) WriteJSON(value interface{})
- func (this *ActionObject) WriteString(output ...string)
- type ActionParamError
- type ActionSpec
- type ActionWrapper
- type ActionWriter
- type Data
- type File
- type Gzip
- type JSON
- type Must
- func (this *Must) BeforeAction(actionPtr ActionWrapper, paramName string) (goNext bool)
- func (this *Must) Code(code int) *Must
- func (this *Must) Email(message string) *Must
- func (this *Must) Equal(value string, message string) *Must
- func (this *Must) Errors() []ActionParamError
- func (this *Must) Expect(fn func() (message string, success bool)) *Must
- func (this *Must) Field(field string, value interface{}) *Must
- func (this *Must) Gt(value int64, message string) *Must
- func (this *Must) Gte(value int64, message string) *Must
- func (this *Must) HasErrors() bool
- func (this *Must) In(values interface{}, message string) *Must
- func (this *Must) Lt(value int64, message string) *Must
- func (this *Must) Lte(value int64, message string) *Must
- func (this *Must) Match(expr string, message string) *Must
- func (this *Must) MaxCharacters(charactersLength int, message string) *Must
- func (this *Must) MaxLength(length int, message string) *Must
- func (this *Must) MinCharacters(charactersLength int, message string) *Must
- func (this *Must) MinLength(length int, message string) *Must
- func (this *Must) Mobile(message string) *Must
- func (this *Must) Require(message string) *Must
- func (this *Must) Trim() *Must
- func (this *Must) Value(value interface{}) *Must
- type Params
- type Session
- func (this *Session) Delete() bool
- func (this *Session) GetBool(key string) bool
- func (this *Session) GetFloat32(key string) float32
- func (this *Session) GetFloat64(key string) float64
- func (this *Session) GetInt(key string) int
- func (this *Session) GetInt32(key string) int32
- func (this *Session) GetInt64(key string) int64
- func (this *Session) GetString(key string) string
- func (this *Session) GetUint(key string) uint
- func (this *Session) GetUint32(key string) uint32
- func (this *Session) GetUint64(key string) uint64
- func (this *Session) SetSid(sid string)
- func (this *Session) Values() map[string]string
- func (this *Session) Write(key, value string) bool
- func (this *Session) WriteInt(key string, value int) bool
- func (this *Session) WriteInt32(key string, value int32) bool
- func (this *Session) WriteInt64(key string, value int64) bool
- func (this *Session) WriteUint(key string, value uint) bool
- func (this *Session) WriteUint32(key string, value uint32) bool
- func (this *Session) WriteUint64(key string, value uint64) bool
- type SessionConfig
- type SessionWrapper
- type Template
- func (this *Template) AddVar(varName, value string) *Template
- func (this *Template) Delims(left, right string) *Template
- func (this *Template) Execute(wr io.Writer, data interface{}) error
- func (this *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error
- func (this *Template) Funcs(funcMap template.FuncMap) *Template
- func (this *Template) HasVar(varName string) bool
- func (this *Template) NewChild(name string) *Template
- func (this *Template) Parse(text string) (*Template, error)
- func (this *Template) SetVars(vars maps.Map) *Template
- func (this *Template) VarValue(varName string) string
- type TemplateCache
- type Testing
- func (this *Testing) AddHeader(key string, value string) *Testing
- func (this *Testing) Cost() *Testing
- func (this *Testing) Method(method string) *Testing
- func (this *Testing) Params(params Params) *Testing
- func (this *Testing) RemoteAddr(remoteAddr string) *Testing
- func (this *Testing) Run(t *testing.T) *TestingResponseWriter
- func (this *Testing) SetHeader(key string, value string) *Testing
- func (this *Testing) URL(urlString string) *Testing
- type TestingResponseWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunAction ¶
func RunAction(actionPtr interface{}, spec *ActionSpec, request *http.Request, responseWriter http.ResponseWriter, params Params, helpers []interface{}, initData Data, ) interface{}
RunAction 执行某个Action
Types ¶
type Action ¶
type Action struct {
ActionObject
}
type ActionContext ¶
type ActionContext struct {
// contains filtered or unexported fields
}
ActionContext 上下文变量容器
func (*ActionContext) GetBool ¶
func (this *ActionContext) GetBool(key string) bool
GetBool 获取bool变量
func (*ActionContext) GetInt64 ¶
func (this *ActionContext) GetInt64(key string) int64
GetInt64 获取int64变量
func (*ActionContext) GetString ¶
func (this *ActionContext) GetString(key string) string
GetString 获取string变量
type ActionObject ¶
type ActionObject struct { Spec *ActionSpec Request *http.Request ResponseWriter http.ResponseWriter ParamsMap Params Context *ActionContext Module string Code int Data Data Message string SessionManager interface{} Files []*File // contains filtered or unexported fields }
func (*ActionObject) AddCookie ¶
func (this *ActionObject) AddCookie(cookie *http.Cookie)
AddCookie 设置cookie
func (*ActionObject) AddHeader ¶
func (this *ActionObject) AddHeader(name, value string)
AddHeader 设置头部信息
func (*ActionObject) FailField ¶
func (this *ActionObject) FailField(field string, message ...string)
FailField 字段错误提示
func (*ActionObject) HasParam ¶
func (this *ActionObject) HasParam(name string) bool
HasParam 判断是否有参数
func (*ActionObject) HasPrefix ¶
func (this *ActionObject) HasPrefix(prefix ...string) bool
HasPrefix 判断URL的Path部分是否包含任一前缀
func (*ActionObject) Next ¶
func (this *ActionObject) Next(nextAction string, params map[string]interface{}, hash ...string) *ActionObject
Next 设置下一个动作
func (*ActionObject) Param ¶
func (this *ActionObject) Param(name string) (value string, found bool)
Param 获取参数
func (*ActionObject) ParamArray ¶
func (this *ActionObject) ParamArray(name string) []string
ParamArray 获取参数数组
func (*ActionObject) ParamInt64 ¶
func (this *ActionObject) ParamInt64(name string) int64
ParamInt64 获取int64参数
func (*ActionObject) ParamString ¶
func (this *ActionObject) ParamString(name string) string
ParamString 获取字符串参数
func (*ActionObject) RequestRemoteAddr ¶
func (this *ActionObject) RequestRemoteAddr() string
RequestRemoteAddr 获取客户端的地址,有可能会包含端口
func (*ActionObject) RequestRemoteIP ¶
func (this *ActionObject) RequestRemoteIP() string
RequestRemoteIP 获取客户端的地址
func (*ActionObject) SetMaxSize ¶
func (this *ActionObject) SetMaxSize(maxSize float64)
SetMaxSize 设置能接收的最大数据(字节)
func (*ActionObject) SetParam ¶
func (this *ActionObject) SetParam(name, value string)
SetParam 设置参数
func (*ActionObject) SetSessionCookieName ¶
func (this *ActionObject) SetSessionCookieName(cookieName string)
SetSessionCookieName 设置Session Cookie名称
func (*ActionObject) SetSessionManager ¶
func (this *ActionObject) SetSessionManager(sessionManager interface{})
SetSessionManager 设置Session管理器
func (*ActionObject) TemplateFilter ¶
func (this *ActionObject) TemplateFilter(filter func(body []byte) []byte)
TemplateFilter 设置模板过滤器
func (*ActionObject) ViewFunc ¶
func (this *ActionObject) ViewFunc(name string, f interface{})
ViewFunc 设置模板文件中可以使用的自定义函数
func (*ActionObject) Write ¶
func (this *ActionObject) Write(bytes []byte) (n int, err error)
输出二进制字节
func (*ActionObject) WriteFormat ¶
func (this *ActionObject) WriteFormat(format string, args ...interface{}) (n int, err error)
WriteFormat 输出可以格式化的内容
func (*ActionObject) WriteJSON ¶
func (this *ActionObject) WriteJSON(value interface{})
WriteJSON 写入JSON
func (*ActionObject) WriteString ¶
func (this *ActionObject) WriteString(output ...string)
WriteString 输出内容
type ActionParamError ¶
type ActionSpec ¶
type ActionSpec struct { Type reflect.Type BeforeFunc *reflect.Value AfterFunc *reflect.Value FuncMap map[string]*reflect.Value Module string PkgPath string ClassName string caches.CacheFactory Context *ActionContext }
ActionSpec Action相关定义
func (*ActionSpec) HasClassPrefix ¶
func (this *ActionSpec) HasClassPrefix(prefix ...string) bool
HasClassPrefix class名是否包含任一前缀
func (*ActionSpec) NewPtrValue ¶
func (this *ActionSpec) NewPtrValue() reflect.Value
NewPtrValue 新建一个Action指针
type ActionWrapper ¶
type ActionWrapper interface {
Object() *ActionObject
}
ActionWrapper 读取ActionObject对象的接口
type ActionWriter ¶
type File ¶
type File struct { OriginFile *multipart.FileHeader Filename string Size int64 Field string Ext string ContentType string }
File 上传的文件封装
type Gzip ¶
type Gzip struct { Level int // contains filtered or unexported fields }
func (*Gzip) AfterAction ¶
func (this *Gzip) AfterAction()
func (*Gzip) BeforeAction ¶
func (this *Gzip) BeforeAction(ptr ActionWrapper, paramName string) (goNext bool)
type Must ¶
type Must struct {
// contains filtered or unexported fields
}
func (*Must) BeforeAction ¶
func (this *Must) BeforeAction(actionPtr ActionWrapper, paramName string) (goNext bool)
func (*Must) Errors ¶
func (this *Must) Errors() []ActionParamError
func (*Must) MaxCharacters ¶
最大字符长度
func (*Must) MinCharacters ¶
最小字符长度
type Session ¶
type Session struct { Sid string Manager interface{} }
Session定义
func (*Session) WriteUint32 ¶
写入uint32值
type SessionWrapper ¶
type SessionWrapper interface { Init(config *SessionConfig) Read(sid string) map[string]string WriteItem(sid string, key string, value string) bool Delete(sid string) bool }
SESSION管理器接口
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template 模板定义
func (*Template) ExecuteTemplate ¶
ExecuteTemplate 执行模板
type TemplateCache ¶
type TemplateCache struct {
// contains filtered or unexported fields
}
type Testing ¶
type Testing struct {
// contains filtered or unexported fields
}
type TestingResponseWriter ¶
type TestingResponseWriter struct {
Data []byte
}
func (*TestingResponseWriter) Header ¶
func (this *TestingResponseWriter) Header() http.Header
func (*TestingResponseWriter) Write ¶
func (this *TestingResponseWriter) Write(data []byte) (int, error)
func (*TestingResponseWriter) WriteHeader ¶
func (this *TestingResponseWriter) WriteHeader(int)