mvc

package
v2.18.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

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.

Index

Constants

View Source
const (
	NO_PERM = -2 //无权限
	NO_AUTH = -1 //未登录
	FAILURE = 0  //操作失败
	SUCCESS = 1  //操作成功
)

Variables

View Source
var (
	//SnakeCase 单词全部小写并用下划线连接
	SnakeCase URLConvert = com.SnakeCase

	//LowerCaseFirst 小写首字母
	LowerCaseFirst URLConvert = com.LowerCaseFirst

	//PascalCase 帕斯卡命名法
	PascalCase URLRecovery = com.PascalCase

	//UpperCaseFirst 大写首字母
	UpperCaseFirst URLRecovery = strings.Title
)
View Source
var (
	ErrModuleHasBeenDisabled     = errors.New(`This module has been disabled`)
	ErrModuleHasNotBeenInstalled = errors.New(`This module has not been installed`)
	ErrModuleHasExpired          = errors.New(`This module has expired`)
)
View Source
var (
	DefaultMapperCheck = func(t reflect.Type) bool {
		return t == mapperType
	}
	DefaultContextInitial = func(ctx echo.Context, wrp *Wrapper, controller interface{}, actionName string) (err error, exit bool) {
		return
	}
)

Functions

func HandlerWrapper added in v1.1.1

func HandlerWrapper(h interface{}) echo.Handler

HandlerWrapper 增加对"func(*Context) error"的支持

Types

type After

type After interface {
	After() error
}

After 动态实例中的后置行为

type AfterHandler

type AfterHandler interface {
	After(echo.Context) error
}

AfterHandler 静态实例中的后置行为

type AllowFormat

type AllowFormat interface {
	AllowFormat(urlPath string, extension string) bool
}

type Application added in v1.1.1

type Application struct {
	Core                  *echo.Echo
	Name                  string
	TemplateDir           string
	Resource              *Resource
	RouteTagName          string
	URLConvert            URLConvert  `json:"-" xml:"-"`
	URLRecovery           URLRecovery `json:"-" xml:"-"`
	MaxUploadSize         int64
	RootModuleName        string
	URL                   string
	URLBuilder            *URLBuilder
	DefaultMiddlewares    []interface{} `json:"-" xml:"-"`
	DefaultPreMiddlewares []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
}

Application 定义应用

func App added in v1.1.1

func App(name string) *Application

func New

func New(name string) (s *Application)

New 创建Application实例

func NewWithContext

func NewWithContext(name string, newContext func(*echo.Echo) echo.Context) (s *Application)

NewWithContext 创建Application实例

func (*Application) AddEvent added in v1.1.1

func (s *Application) AddEvent(eventName string, handler interface{}) *Application

AddEvent 添加事件

func (*Application) Commit

func (s *Application) Commit()

Commit 提交并构建路由

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{})

DefaultFuncMap 模板的默认函数

func (*Application) DelEvent added in v1.1.1

func (s *Application) DelEvent(eventName string) *Application

DelEvent 删除事件

func (*Application) Event added in v1.1.1

func (s *Application) Event(eventName string, next func(bool), sessions ...interface{}) *Application

Event 执行事件

func (*Application) FindModuleByDomain added in v1.3.5

func (s *Application) FindModuleByDomain(host string) (*Module, bool)

FindModuleByDomain 根据域名查询对应模块实例

func (*Application) FuncMapCopyTo added in v1.3.0

func (s *Application) FuncMapCopyTo(m map[string]interface{}) *Application

FuncMapCopyTo 获取模板的默认函数副本

func (*Application) GoEvent added in v1.1.1

func (s *Application) GoEvent(eventName string, next func(bool), sessions ...interface{}) *Application

GoEvent 并行执行事件

func (*Application) HasModule added in v1.1.1

func (s *Application) HasModule(name string) bool

HasModule 检查模块是否存在

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

Modules 获取模块列表,如果传递参数值为true,返回所有域名所对应的模块列表

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, *resource.Static)

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

func (s *Application) NewTemplateEngine(tmplPath string, conf *render.Config) driver.Driver

NewTemplateEngine 新建模板引擎实例

func (*Application) Pprof added in v1.1.1

func (s *Application) Pprof() *Application

Pprof 启用pprof

func (*Application) Pre added in v1.3.0

func (s *Application) Pre(middleware ...interface{})

Pre 全局前置中间件

func (*Application) RootDir added in v1.1.1

func (s *Application) RootDir() string

RootDir 网站根目录

func (*Application) Run added in v1.1.1

func (s *Application) Run(args ...interface{})

Run 运行服务

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) SetHTTPErrorOptions added in v1.3.9

func (s *Application) SetHTTPErrorOptions(options *render.Options) *Application

SetHTTPErrorOptions 设置错误处理选项

func (*Application) SetSessionOptions added in v1.1.1

func (s *Application) SetSessionOptions(sessionOptions *echo.SessionOptions) *Application

SetSessionOptions 设置Session配置

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) Theme added in v1.1.1

func (s *Application) Theme() string

Theme 当前使用的主题名称

func (*Application) ThemeDir added in v1.1.1

func (s *Application) ThemeDir(args ...string) string

ThemeDir 主题所在文件夹的路径

func (*Application) Tree added in v1.1.1

func (s *Application) Tree(args ...*echo.Echo) (r map[string]map[string]map[string]map[string]string)

Tree module -> controller -> action -> HTTP-METHODS

func (*Application) Use added in v1.3.0

func (s *Application) Use(middleware ...interface{})

Use 全局中间件

type Before

type Before interface {
	Before() error
}

Before 动态实例中的前置行为

type BeforeHandler

type BeforeHandler interface {
	Before(echo.Context) error
}

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
	// contains filtered or unexported fields
}

func NewContext added in v1.1.1

func NewContext(a *Application, c echo.Context) *Context

func (*Context) Action added in v1.3.5

func (c *Context) Action(ctl string, act string) (err error)

Action 调用控制器方法

func (*Context) Atoe added in v1.1.1

func (c *Context) Atoe(v string) error

Atoe 字符串转error

func (*Context) Body added in v1.1.1

func (c *Context) Body() ([]byte, error)

func (*Context) BuildURL added in v1.1.1

func (c *Context) BuildURL(ctl string, act string, args ...interface{}) string

BuildURL 生成当前Module网址

func (*Context) CheckPath added in v1.3.5

func (c *Context) CheckPath() string

CheckPath 检查权限所用的网址路径

func (*Context) CheckTmplPath added in v1.1.1

func (c *Context) CheckTmplPath(tpath string) string

func (*Context) Display added in v1.1.1

func (c *Context) Display(args ...interface{}) error

func (*Context) ErrorWithCode added in v1.1.1

func (c *Context) ErrorWithCode(code int, args ...string) *echo.HTTPError

ErrorWithCode 生成HTTPError

func (*Context) Exit added in v1.1.1

func (c *Context) Exit(args ...bool) *Context

func (*Context) GenNextURL added in v1.1.1

func (c *Context) GenNextURL(u string) string

GenNextURL 生成安全编码后的下一步网址

func (*Context) GetNextURL added in v1.1.1

func (c *Context) GetNextURL(allowReferer ...bool) string

GetNextURL 自动获取下一步网址

func (*Context) GetSecCookie added in v1.1.1

func (c *Context) GetSecCookie(key string) (value string)

func (*Context) Go added in v1.3.9

func (c *Context) Go(url string, args ...interface{}) error

Go 页面跳转

func (*Context) Goto added in v1.1.1

func (c *Context) Goto(goURL string, args ...interface{}) error

Goto 页面跳转(根据路由生成网址后跳转)

func (*Context) GotoNext added in v1.1.1

func (c *Context) GotoNext(defaultURL ...string) error

GotoNext 跳转到下一步

func (*Context) IP added in v1.1.1

func (c *Context) IP() string

func (*Context) Init added in v1.1.1

func (c *Context) Init(wrp *Wrapper, controller interface{}, actName string) (error, bool)

func (*Context) IsExit added in v1.1.1

func (c *Context) IsExit() bool

func (*Context) ModuleAction added in v1.3.5

func (c *Context) ModuleAction(mod string, ctl string, act string) (err error)

ModuleAction 调用控制器方法

func (*Context) ModuleURL added in v1.1.1

func (c *Context) ModuleURL(mod string, ctl string, act string, args ...interface{}) string

ModuleURL 生成指定Module网址

func (*Context) ModuleURLPath added in v1.3.0

func (c *Context) ModuleURLPath(ppath string, args ...map[string]interface{}) string

ModuleURLPath 生成指定Module网址

func (*Context) NextURL added in v1.1.1

func (c *Context) NextURL(defaultURL ...string) string

NextURL 获取下一步网址

func (*Context) OnlyAjax added in v1.1.1

func (c *Context) OnlyAjax() bool

func (*Context) ParseNextURL added in v1.1.1

func (c *Context) ParseNextURL(next string) string

ParseNextURL 解析下一步网址

func (*Context) PjaxContainer added in v1.1.1

func (c *Context) PjaxContainer() string

func (*Context) Refer added in v1.1.1

func (c *Context) Refer() string

Refer returns http referer header.

func (*Context) Reset added in v1.1.1

func (c *Context) Reset(req engine.Request, resp engine.Response)

func (*Context) RootModuleURL added in v1.3.0

func (c *Context) RootModuleURL(ctl string, act string, args ...interface{}) string

RootModuleURL 生成根Module网址

func (*Context) SecCookie added in v1.1.1

func (c *Context) SecCookie(key string, value interface{})

func (*Context) SetErr added in v1.1.1

func (c *Context) SetErr(args ...interface{}) *Context

SetErr 设置出错类型为“操作失败”(info,zone,data)

func (*Context) SetNoAuth added in v1.1.1

func (c *Context) SetNoAuth(args ...interface{}) *Context

SetNoAuth 设置出错类型为“未登录”(info,zone,data)

func (*Context) SetNoPerm added in v1.1.1

func (c *Context) SetNoPerm(args ...interface{}) *Context

SetNoPerm 设置出错类型为“未授权”(message,for,data)

func (*Context) SetOutput added in v1.1.1

func (c *Context) SetOutput(code int, args ...interface{}) *Context

SetOutput 设置输出(code,info,zone,data)

func (*Context) SetSecCookie added in v1.1.1

func (c *Context) SetSecCookie(key string, value interface{})

func (*Context) SetSuc added in v1.1.1

func (c *Context) SetSuc(args ...interface{}) *Context

SetSuc 设置响应类型为“操作成功”(info,zone,data)

func (*Context) SetSucData added in v1.1.1

func (c *Context) SetSucData(data interface{}) *Context

SetSucData 设置成功返回的数据

func (*Context) SetTmpl added in v1.1.1

func (c *Context) SetTmpl(args ...string) *Context

SetTmpl 指定要渲染的模板路径

func (*Context) SubDomain added in v1.1.1

func (c *Context) SubDomain() string

SubDomain returns sub domain string. if aa.bb.domain.com, returns aa.bb .

func (*Context) TmplPath added in v1.1.1

func (c *Context) TmplPath(args ...string) string

TmplPath 生成模板路径 args: ActionName,ControllerName,ModuleName

func (*Context) U added in v1.1.1

func (c *Context) U(args ...string) (s string)

U 网址生成 @usage: c.U(moduleName,controllerName,actionName) or c.U(moduleName,controllerName,actionName,`?q=coscms`) c.U(controllerName,actionName) or c.U(controllerName,actionName,`?q=coscms`) c.U(actionName) or or c.U(actionName,`?q=coscms`)

func (*Context) URLFor added in v1.1.1

func (c *Context) URLFor(mod string, ctl string, act string, args ...interface{}) string

URLFor ModuleURL的别名。生成指定Module网址

func (*Context) URLPath added in v1.3.0

func (c *Context) URLPath(ppath string, args ...map[string]interface{}) string

URLPath 生成当前Module网址

type ContextInitial added in v1.1.1

type ContextInitial interface {
	Init(*Wrapper, interface{}, string) (error, bool)
}

type Controller added in v1.1.1

type Controller struct {
	*Context
	logger.Logger
}

func NewController added in v1.1.1

func NewController(c echo.Context) *Controller

func (*Controller) Init added in v1.1.1

func (a *Controller) Init(c echo.Context) error

type ExitChecker

type ExitChecker interface {
	IsExit() bool
}

type Handler

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

func NewHandler

func NewHandler(h func(echo.Context) error, name string) *Handler

func (*Handler) Handle

func (h *Handler) Handle(c echo.Context) error

func (*Handler) Name added in v1.3.5

func (h *Handler) Name() string

type Initer

type Initer interface {
	Init(echo.Context) error
}

Initer 动态实例中的初始化行为

type IniterFunc added in v1.1.1

type IniterFunc func(interface{}) error

type Main

type Main interface {
	Main() error
}

Main 动态实例中的行为入口

type Mapper

type Mapper struct{}

Mapper 结构体中定义路由的字段类型

type Module

type Module struct {
	*Application   `json:"-" xml:"-"`
	Group          *echo.Group   `json:"-" xml:"-"`
	Handler        *echo.Echo    `json:"-" xml:"-"` //指定域名时有效
	PreMiddlewares []interface{} `json:"-" xml:"-"`
	Middlewares    []interface{} `json:"-" xml:"-"`
	Renderer       driver.Driver `json:"-" xml:"-"`
	Resource       *resource.Static
	Name           string
	Domain         string

	URL string
	Dir string

	// 模块附加信息
	Disabled    int64  // 禁用时间戳,为0时为启用状态
	Installed   int64  // 安装时间戳,为0时为未安装
	Expired     int64  // 过期时间戳,为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) Add added in v1.3.0

func (a *Module) Add(args ...interface{}) *Module

Add 批量注册控制器路由

func (*Module) AddHandler

func (a *Module) AddHandler(c interface{}) *Wrapper

AddHandler 登记控制器

func (*Module) C

func (a *Module) C(name string) (c interface{})

C 获取控制器

func (*Module) ClearCachedHandlerNames

func (a *Module) ClearCachedHandlerNames()

func (*Module) Commit

func (a *Module) Commit()

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

func (a *Module) InitRenderer(conf *render.Config, funcMap map[string]interface{}) *Module

InitRenderer 初始化渲染接口(用于单独对app指定renderer,如不指定,默认会使用Server中Renderer)

func (*Module) Pre added in v1.3.0

func (a *Module) Pre(middleware ...interface{})

Pre 前置中间件

func (*Module) Register

func (a *Module) Register(p string, v interface{}, methods ...string) *Module

Register 注册路由:module.Register(`/index`,Index.Index,"GET","POST")

func (*Module) Router

func (a *Module) Router() echo.ICore

func (*Module) SafelyCall

func (a *Module) SafelyCall(fn reflect.Value, args []reflect.Value) (resp []reflect.Value, err error)

SafelyCall invokes `function` in recover block

func (*Module) Use

func (a *Module) Use(middleware ...interface{})

Use 中间件

func (*Module) Valid

func (a *Module) Valid() error

func (*Module) Wrapper

func (a *Module) Wrapper(name string) (wp *Wrapper)

Wrapper 获取封装器

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 Resource added in v1.3.0

type Resource struct {
	*resource.Static
	Dir string //静态资源所在文件夹
}

Resource 静态资源

type StaticIniter

type StaticIniter interface {
	Init(wrp *Wrapper, act string) error
}

type URLBuilder added in v1.3.5

type URLBuilder struct {
	*Application `json:"-" xml:"-"`
	// contains filtered or unexported fields
}

func NewURLBuilder added in v1.3.5

func NewURLBuilder(project string, mvc *Application) *URLBuilder

func (*URLBuilder) AllowFormat added in v1.3.5

func (a *URLBuilder) AllowFormat(key string, ext string) (ok bool)

func (*URLBuilder) Build added in v1.3.5

func (a *URLBuilder) Build(mdl string, ctl string, act string, params ...interface{}) (r string)

func (*URLBuilder) BuildFromPath added in v1.3.5

func (a *URLBuilder) BuildFromPath(ppath string, args ...map[string]interface{}) (r string)

func (*URLBuilder) Set added in v1.3.5

func (a *URLBuilder) Set(h interface{}) (pkg string, ctl string, act string)

func (*URLBuilder) SetExtensions added in v1.3.5

func (a *URLBuilder) SetExtensions(key string, exts []string) *URLBuilder

func (*URLBuilder) SetProjectPath added in v1.3.5

func (a *URLBuilder) SetProjectPath(projectPath string)

type URLConvert

type URLConvert func(string) string

URLConvert 网址转换

type URLRecovery

type URLRecovery func(string) string

URLRecovery 网址还原

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) Auto

func (a *Wrapper) Auto(args ...interface{})

Auto 自动注册动态实例的路由:a.Auto()

func (*Wrapper) Exec

func (a *Wrapper) Exec(ctx echo.Context, t reflect.Type, action string) error

func (*Wrapper) Name

func (a *Wrapper) Name(h interface{}) string

func (*Wrapper) Register

func (a *Wrapper) Register(p string, h interface{}, methods ...string) *Wrapper

Register 路由注册方案1:注册函数(可匿名)或静态实例的成员函数 例如:Register(`/index`,Index.Index,"GET","POST")

func (*Wrapper) RouteMethods

func (a *Wrapper) RouteMethods()

RouteMethods 路由注册方案3:自动注册动态实例内带HTTP方法名后缀的成员函数作为路由

func (*Wrapper) RouteTags

func (a *Wrapper) RouteTags()

RouteTags 路由注册方案2:从动态实例内Mapper类型字段标签中获取路由信息

Directories

Path Synopsis
static
minify
Package cssmin minifies CSS.
Package cssmin minifies CSS.

Jump to

Keyboard shortcuts

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