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.
Index ¶
- Variables
- type After
- type AfterHandler
- type AllowFormat
- type Before
- type BeforeHandler
- type ExitChecker
- type Handler
- type Initer
- type MVC
- func (s *MVC) AddEvent(eventName string, handler interface{}) *MVC
- func (s *MVC) Debug(on bool) *MVC
- func (s *MVC) DelEvent(eventName string) *MVC
- func (s *MVC) Event(eventName string, next func(bool), sessions ...interface{}) *MVC
- func (s *MVC) GoEvent(eventName string, next func(bool), sessions ...interface{}) *MVC
- func (s *MVC) HasModule(name string) bool
- func (s *MVC) InitStatic() *MVC
- func (s *MVC) LoadConfig(file string, config interface{}) error
- func (s *MVC) Module(args ...string) *Module
- func (s *MVC) ModuleOk(args ...string) (app *Module, ok bool)
- func (s *MVC) Modules(args ...bool) map[string]*Module
- func (s *MVC) NewModule(name string, middlewares ...interface{}) *Module
- func (s *MVC) NewRenderer(conf *render.Config, a *Module, funcMap map[string]interface{}) driver.Driver
- func (s *MVC) NewStatic(urlPath string, absPath string, f ...map[string]interface{}) *resource.Static
- func (s *MVC) NewTemplateEngine(tmplPath string, conf *render.Config) driver.Driver
- func (s *MVC) RootDir() string
- func (s *MVC) Run(args ...interface{})
- func (s *MVC) ServeHTTP(r engine.Request, w engine.Response)
- func (s *MVC) SetDomain(name string, domain string) *MVC
- func (s *MVC) SetSessionOptions(sessionOptions *echo.SessionOptions) *MVC
- func (s *MVC) SetTheme(conf *render.Config) *MVC
- func (s *MVC) TemplateMonitor() *MVC
- func (s *MVC) Theme() string
- func (s *MVC) ThemeDir(args ...string) string
- 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 ¶
This section is empty.
Variables ¶
var ( ErrAppHasBeenDisabled = errors.New(`This module has been disabled`) ErrAppHasNotBeenInstalled = errors.New(`This module has not been installed`) ErrAppHasExpired = errors.New(`This module has expired`) )
var ( //SnakeCase 单词全部小写并用下划线连接 SnakeCase URLConvert = com.SnakeCase //LowerCaseFirst 小写首字母 LowerCaseFirst URLConvert = com.LowerCaseFirst //PascalCase 帕斯卡命名法 PascalCase URLRecovery = com.PascalCase //UpperCaseFirst 大写首字母 UpperCaseFirst URLRecovery = strings.Title )
Functions ¶
This section is empty.
Types ¶
type AfterHandler ¶
AfterHandler 静态实例中的后置行为
type AllowFormat ¶
type BeforeHandler ¶
BeforeHandler 静态实例中的前置行为
type ExitChecker ¶
type ExitChecker interface {
IsExit() bool
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) HandleName ¶
type MVC ¶
type MVC 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:"-"` // contains filtered or unexported fields }
func NewWithContext ¶
func NewWithContext(name string, newContext func(*echo.Echo) echo.Context, middlewares ...interface{}) (s *MVC)
NewWithContext 创建MVC实例
func (*MVC) LoadConfig ¶
LoadConfig 载入confl支持的配置文件
func (*MVC) NewRenderer ¶
func (s *MVC) NewRenderer(conf *render.Config, a *Module, funcMap map[string]interface{}) driver.Driver
NewRenderer 新建渲染接口
func (*MVC) NewStatic ¶
func (s *MVC) NewStatic(urlPath string, absPath string, f ...map[string]interface{}) *resource.Static
NewStatic 新建静态资源实例
func (*MVC) NewTemplateEngine ¶
NewTemplateEngine 新建模板引擎实例
func (*MVC) SetSessionOptions ¶
func (s *MVC) SetSessionOptions(sessionOptions *echo.SessionOptions) *MVC
type Module ¶
type Module struct { *MVC `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 (*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 { *MVC `json:"-" xml:"-"` // contains filtered or unexported fields }
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方法名后缀的成员函数作为路由