Documentation ¶
Overview ¶
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the `License`); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an `AS IS` BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func HandlerWrapper(h interface{}) echo.Handler
- type After
- type AfterHandler
- type AllowFormat
- type Application
- func (s *Application) AddEvent(eventName string, handler interface{}) *Application
- func (s *Application) Debug(on bool) *Application
- func (s *Application) DefaultFuncMap() (r map[string]interface{})
- func (s *Application) DelEvent(eventName string) *Application
- func (s *Application) Event(eventName string, next func(bool), sessions ...interface{}) *Application
- func (s *Application) GoEvent(eventName string, next func(bool), sessions ...interface{}) *Application
- func (s *Application) HasModule(name string) bool
- func (s *Application) InitCodec(hashKey []byte, blockKey []byte)
- func (s *Application) InitStatic() *Application
- func (s *Application) LoadConfig(file string, config interface{}) error
- func (s *Application) Module(args ...string) *Module
- func (s *Application) ModuleOk(args ...string) (app *Module, ok bool)
- func (s *Application) Modules(args ...bool) map[string]*Module
- func (s *Application) NewModule(name string, middlewares ...interface{}) *Module
- func (s *Application) NewRenderer(conf *render.Config, a *Module, funcMap map[string]interface{}) driver.Driver
- func (s *Application) NewStatic(urlPath string, absPath string, f ...map[string]interface{}) *resource.Static
- func (s *Application) NewTemplateEngine(tmplPath string, conf *render.Config) driver.Driver
- func (s *Application) Pprof() *Application
- func (s *Application) RootDir() string
- func (s *Application) Run(args ...interface{})
- func (s *Application) ServeHTTP(r engine.Request, w engine.Response)
- func (s *Application) SetDomain(name string, domain string) *Application
- func (s *Application) SetErrorPages(templates map[int]string, options ...*render.Options) *Application
- func (s *Application) SetSessionOptions(sessionOptions *echo.SessionOptions) *Application
- func (s *Application) SetTheme(conf *render.Config) *Application
- func (s *Application) TemplateMonitor() *Application
- func (s *Application) Theme() string
- func (s *Application) ThemeDir(args ...string) string
- func (s *Application) Tree(args ...*echo.Echo) (r map[string]map[string]map[string]map[string]string)
- type Before
- type BeforeHandler
- type Context
- func (c *Context) A(ctl string, act string) (err error)
- func (c *Context) Assign(key string, val interface{}) *Context
- func (c *Context) Assignx(values *map[string]interface{}) *Context
- func (c *Context) Atoe(v string) error
- func (c *Context) Body() ([]byte, error)
- func (c *Context) BuildURL(ctl string, act string, args ...interface{}) string
- func (c *Context) CheckTmplPath(tpath string) string
- func (c *Context) Display(args ...interface{}) error
- func (c *Context) ErrorWithCode(code int, args ...string) *echo.HTTPError
- func (c *Context) Exit(args ...bool) *Context
- func (c *Context) GenNextURL(u string) string
- func (c *Context) GetNextURL() string
- func (c *Context) GetSecCookie(key string) (value string)
- func (c *Context) Goto(goURL string, args ...interface{}) error
- func (c *Context) GotoNext(defaultURL ...string) error
- func (c *Context) IP() string
- func (c *Context) Init(wrp *Wrapper, controller interface{}, actName string) (error, bool)
- func (c *Context) IsExit() bool
- func (c *Context) ModuleURL(mod string, ctl string, act string, args ...interface{}) string
- func (c *Context) ModuleURLFor(ppath string, args ...map[string]interface{}) string
- func (c *Context) NextURL(defaultURL ...string) string
- func (c *Context) OnlyAjax() bool
- func (c *Context) ParseNextURL(next string) string
- func (c *Context) PjaxContainer() string
- func (c *Context) Redir(url string, args ...interface{}) error
- func (c *Context) Refer() string
- func (c *Context) Reset(req engine.Request, resp engine.Response)
- func (c *Context) SecCookie(key string, value interface{})
- func (c *Context) SetErr(args ...interface{}) *Context
- func (c *Context) SetNoAuth(args ...interface{}) *Context
- func (c *Context) SetNoPerm(args ...interface{}) *Context
- func (c *Context) SetOutput(code int, args ...interface{}) *Context
- func (c *Context) SetSecCookie(key string, value interface{})
- func (c *Context) SetSuc(args ...interface{}) *Context
- func (c *Context) SetSucData(data interface{}) *Context
- func (c *Context) SetTmpl(args ...string) *Context
- func (c *Context) SubDomain() string
- func (c *Context) TmplPath(args ...string) string
- func (c *Context) U(args ...string) (s string)
- func (c *Context) URLFor(ppath string, args ...map[string]interface{}) string
- type ContextInitial
- type Controller
- type Data
- type ExitChecker
- type Handler
- type Initer
- type IniterFunc
- type Main
- type Mapper
- type Module
- func (a *Module) AddHandler(c interface{}) *Wrapper
- func (a *Module) C(name string) (c interface{})
- func (a *Module) ClearCachedHandlerNames()
- func (a *Module) ExecAction(action string, t reflect.Type, v reflect.Value, c echo.Context) (err error)
- func (a *Module) InitRenderer(conf *render.Config, funcMap map[string]interface{}) *Module
- func (a *Module) Register(p string, v interface{}, methods ...string) *Module
- func (a *Module) Router() echo.ICore
- func (a *Module) SafelyCall(fn reflect.Value, args []reflect.Value) (resp []reflect.Value, err error)
- func (a *Module) Use(args ...interface{}) *Module
- func (a *Module) Valid() error
- func (a *Module) Wrapper(name string) (wp *Wrapper)
- type ModuleConfig
- func (a *ModuleConfig) Config() interface{}
- func (a *ModuleConfig) Get(recvFn func(interface{}))
- func (a *ModuleConfig) Init(config interface{}) ModuleConfiger
- func (a *ModuleConfig) IsValid() bool
- func (a *ModuleConfig) Set(data string) error
- func (a *ModuleConfig) SetTemplate(tmplFile string) ModuleConfiger
- func (a *ModuleConfig) String() string
- func (a *ModuleConfig) Template() string
- type ModuleConfiger
- type StaticIniter
- type URLConvert
- type URLRecovery
- type URLs
- func (a *URLs) AllowFormat(key string, ext string) (ok bool)
- func (a *URLs) Build(mdl string, ctl string, act string, params ...interface{}) (r string)
- func (a *URLs) BuildFromPath(ppath string, args ...map[string]interface{}) (r string)
- func (a *URLs) Set(h interface{}) (pkg string, ctl string, act string)
- func (a *URLs) SetExtensions(key string, exts []string) *URLs
- func (a *URLs) SetProjectPath(projectPath string)
- type Wrapper
- func (a *Wrapper) Auto(args ...interface{})
- func (a *Wrapper) Exec(ctx echo.Context, t reflect.Type, action string) error
- func (a *Wrapper) HandleName(h interface{}) string
- func (a *Wrapper) Register(p string, h interface{}, methods ...string) *Wrapper
- func (a *Wrapper) RouteMethods()
- func (a *Wrapper) RouteTags()
Constants ¶
const ( NO_PERM = -2 //无权限 NO_AUTH = -1 //未登录 FAILURE = 0 //操作失败 SUCCESS = 1 //操作成功 )
Variables ¶
var ( //SnakeCase 单词全部小写并用下划线连接 SnakeCase URLConvert = com.SnakeCase //LowerCaseFirst 小写首字母 LowerCaseFirst URLConvert = com.LowerCaseFirst //PascalCase 帕斯卡命名法 PascalCase URLRecovery = com.PascalCase //UpperCaseFirst 大写首字母 UpperCaseFirst URLRecovery = strings.Title )
Functions ¶
func HandlerWrapper ¶ added in v1.1.1
Types ¶
type AfterHandler ¶
AfterHandler 静态实例中的后置行为
type AllowFormat ¶
type Application ¶ added in v1.1.1
type Application struct { Core *echo.Echo Name string TemplateDir string StaticDir string StaticRes *resource.Static RouteTagName string URLConvert URLConvert `json:"-" xml:"-"` URLRecovery URLRecovery `json:"-" xml:"-"` MaxUploadSize int64 RootModuleName string URL string URLs *URLs DefaultMiddlewares []interface{} `json:"-" xml:"-"` SessionOptions *echo.SessionOptions Renderer driver.Driver `json:"-" xml:"-"` FuncMap map[string]interface{} `json:"-" xml:"-"` ContextCreator func(*echo.Echo) echo.Context `json:"-" xml:"-"` ContextInitial func(echo.Context, *Wrapper, interface{}, string) (error, bool) `json:"-" xml:"-"` Codec codec.Codec `json:"-" xml:"-"` MapperCheck func(t reflect.Type) bool `json:"-" xml:"-"` // contains filtered or unexported fields }
func App ¶ added in v1.1.1
func App(name string) *Application
func NewWithContext ¶
func NewWithContext(name string, newContext func(*echo.Echo) echo.Context, middlewares ...interface{}) (s *Application)
NewWithContext 创建Application实例
func (*Application) AddEvent ¶ added in v1.1.1
func (s *Application) AddEvent(eventName string, handler interface{}) *Application
func (*Application) Debug ¶ added in v1.1.1
func (s *Application) Debug(on bool) *Application
Debug 开关debug模式
func (*Application) DefaultFuncMap ¶ added in v1.1.1
func (s *Application) DefaultFuncMap() (r map[string]interface{})
func (*Application) DelEvent ¶ added in v1.1.1
func (s *Application) DelEvent(eventName string) *Application
func (*Application) Event ¶ added in v1.1.1
func (s *Application) Event(eventName string, next func(bool), sessions ...interface{}) *Application
func (*Application) GoEvent ¶ added in v1.1.1
func (s *Application) GoEvent(eventName string, next func(bool), sessions ...interface{}) *Application
func (*Application) HasModule ¶ added in v1.1.1
func (s *Application) HasModule(name string) bool
func (*Application) InitCodec ¶ added in v1.1.1
func (s *Application) InitCodec(hashKey []byte, blockKey []byte)
InitCodec 初始化 加密/解密 接口
func (*Application) InitStatic ¶ added in v1.1.1
func (s *Application) InitStatic() *Application
InitStatic 初始化静态资源
func (*Application) LoadConfig ¶ added in v1.1.1
func (s *Application) LoadConfig(file string, config interface{}) error
LoadConfig 载入confl支持的配置文件
func (*Application) Module ¶ added in v1.1.1
func (s *Application) Module(args ...string) *Module
Module 获取模块实例
func (*Application) ModuleOk ¶ added in v1.1.1
func (s *Application) ModuleOk(args ...string) (app *Module, ok bool)
ModuleOk 获取模块实例
func (*Application) Modules ¶ added in v1.1.1
func (s *Application) Modules(args ...bool) map[string]*Module
func (*Application) NewModule ¶ added in v1.1.1
func (s *Application) NewModule(name string, middlewares ...interface{}) *Module
NewModule 创建新模块
func (*Application) NewRenderer ¶ added in v1.1.1
func (s *Application) NewRenderer(conf *render.Config, a *Module, funcMap map[string]interface{}) driver.Driver
NewRenderer 为特殊module(比如admin)单独新建渲染接口
func (*Application) NewStatic ¶ added in v1.1.1
func (s *Application) NewStatic(urlPath string, absPath string, f ...map[string]interface{}) *resource.Static
NewStatic 新建静态资源实例
func (*Application) NewTemplateEngine ¶ added in v1.1.1
NewTemplateEngine 新建模板引擎实例
func (*Application) Pprof ¶ added in v1.1.1
func (s *Application) Pprof() *Application
Pprof 启用pprof
func (*Application) ServeHTTP ¶ added in v1.1.1
func (s *Application) ServeHTTP(r engine.Request, w engine.Response)
ServeHTTP HTTP服务执行入口
func (*Application) SetDomain ¶ added in v1.1.1
func (s *Application) SetDomain(name string, domain string) *Application
SetDomain 为模块设置域名
func (*Application) SetErrorPages ¶ added in v1.1.1
func (s *Application) SetErrorPages(templates map[int]string, options ...*render.Options) *Application
func (*Application) SetSessionOptions ¶ added in v1.1.1
func (s *Application) SetSessionOptions(sessionOptions *echo.SessionOptions) *Application
func (*Application) SetTheme ¶ added in v1.1.1
func (s *Application) SetTheme(conf *render.Config) *Application
SetTheme 设置模板主题
func (*Application) TemplateMonitor ¶ added in v1.1.1
func (s *Application) TemplateMonitor() *Application
TemplateMonitor 模板监控事件
func (*Application) ThemeDir ¶ added in v1.1.1
func (s *Application) ThemeDir(args ...string) string
ThemeDir 主题所在文件夹的路径
type BeforeHandler ¶
BeforeHandler 静态实例中的前置行为
type Context ¶ added in v1.1.1
type Context struct { echo.Context Application *Application Module *Module C interface{} ControllerName string ActionName string Tmpl string Output Data // contains filtered or unexported fields }
func NewContext ¶ added in v1.1.1
func NewContext(a *Application, c echo.Context) *Context
func (*Context) CheckTmplPath ¶ added in v1.1.1
func (*Context) ErrorWithCode ¶ added in v1.1.1
ErrorWithCode 生成HTTPError
func (*Context) GenNextURL ¶ added in v1.1.1
GenNextURL 生成安全编码后的下一步网址
func (*Context) GetNextURL ¶ added in v1.1.1
GetNextURL 自动获取下一步网址
func (*Context) GetSecCookie ¶ added in v1.1.1
func (*Context) ModuleURLFor ¶ added in v1.1.1
ModuleURLFor 生成指定Module网址
func (*Context) ParseNextURL ¶ added in v1.1.1
ParseNextURL 解析下一步网址
func (*Context) PjaxContainer ¶ added in v1.1.1
func (*Context) SetSecCookie ¶ added in v1.1.1
func (*Context) SetSucData ¶ added in v1.1.1
SetSucData 设置成功返回的数据
func (*Context) SubDomain ¶ added in v1.1.1
SubDomain returns sub domain string. if aa.bb.domain.com, returns aa.bb .
type ContextInitial ¶ added in v1.1.1
type Controller ¶ added in v1.1.1
func NewController ¶ added in v1.1.1
func NewController(c echo.Context) *Controller
type Data ¶ added in v1.1.1
type Data interface { Assign(key string, val interface{}) Assignx(values *map[string]interface{}) SetTmplFuncs() Render(tmpl string, code ...int) error String() string Set(code int, args ...interface{}) Gets() (code echo.State, info interface{}, zone interface{}, data interface{}) GetData() interface{} }
type ExitChecker ¶
type ExitChecker interface {
IsExit() bool
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) HandleName ¶
type IniterFunc ¶ added in v1.1.1
type IniterFunc func(interface{}) error
type Module ¶
type Module struct { *Application `json:"-" xml:"-"` Group *echo.Group `json:"-" xml:"-"` Handler *echo.Echo `json:"-" xml:"-"` //指定域名时有效 Middlewares []interface{} `json:"-" xml:"-"` Renderer driver.Driver `json:"-" xml:"-"` Name string Domain string URL string Dir string // 模块附加信息 Disabled int // 禁用时间戳,为0时为启用状态 Installed int // 安装时间戳,为0时为未安装 Expired int // 过期时间戳,为0时为永不过期 Author string // 作者名称 Website string // 作者网址 Email string // 作者邮箱 Description string // 简介 Config ModuleConfiger // 安装和卸载逻辑 Install func() error `json:"-" xml:"-"` Uninstall func() error `json:"-" xml:"-"` // contains filtered or unexported fields }
func NewModule ¶
func NewModule(name string, domain string, s *Application, middlewares ...interface{}) (a *Module)
func (*Module) ClearCachedHandlerNames ¶
func (a *Module) ClearCachedHandlerNames()
func (*Module) ExecAction ¶
func (a *Module) ExecAction(action string, t reflect.Type, v reflect.Value, c echo.Context) (err error)
ExecAction 执行Action的通用方式
func (*Module) InitRenderer ¶
InitRenderer 初始化渲染接口(用于单独对app指定renderer,如不指定,默认会使用Server中Renderer)
type ModuleConfig ¶
type ModuleConfig struct {
// contains filtered or unexported fields
}
func (*ModuleConfig) Config ¶
func (a *ModuleConfig) Config() interface{}
func (*ModuleConfig) Get ¶
func (a *ModuleConfig) Get(recvFn func(interface{}))
Get usage: var appConf *map[string]string
a.Get(func(conf interface{}){ if v, y := conf.(*map[string]string); y { appConf = v } })
func (*ModuleConfig) Init ¶
func (a *ModuleConfig) Init(config interface{}) ModuleConfiger
func (*ModuleConfig) IsValid ¶
func (a *ModuleConfig) IsValid() bool
func (*ModuleConfig) Set ¶
func (a *ModuleConfig) Set(data string) error
Set usage: var appConf map[string]string a.Set(`{"Name":"webx"}`)
func (*ModuleConfig) SetTemplate ¶
func (a *ModuleConfig) SetTemplate(tmplFile string) ModuleConfiger
func (*ModuleConfig) String ¶
func (a *ModuleConfig) String() string
func (*ModuleConfig) Template ¶
func (a *ModuleConfig) Template() string
type ModuleConfiger ¶
type ModuleConfiger interface { Init(conf interface{}) ModuleConfiger Set(data string) error Get(recvFn func(interface{})) Config() interface{} IsValid() bool String() string Template() string //获取表单模板名称 SetTemplate(tmplFile string) ModuleConfiger //获取设置表单模板 }
type StaticIniter ¶
type URLs ¶
type URLs struct { *Application `json:"-" xml:"-"` // contains filtered or unexported fields }
func NewURLs ¶
func NewURLs(project string, mvc *Application) *URLs
func (*URLs) BuildFromPath ¶
func (*URLs) SetProjectPath ¶
type Wrapper ¶
type Wrapper struct { // 实例对象 Controller interface{} `json:"-" xml:"-"` RouteRegister echo.RouteRegister `json:"-" xml:"-"` Module *Module `json:"-" xml:"-"` ControllerName string // contains filtered or unexported fields }
func (*Wrapper) HandleName ¶
func (*Wrapper) Register ¶
Register 路由注册方案1:注册函数(可匿名)或静态实例的成员函数 例如:Register(`/index`,Index.Index,"GET","POST")
func (*Wrapper) RouteMethods ¶
func (a *Wrapper) RouteMethods()
RouteMethods 路由注册方案3:自动注册动态实例内带HTTP方法名后缀的成员函数作为路由