gmvc

package
v0.0.0-...-c9a36a8 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

MVC

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	Request  *ghttp.Request  // 请求数据对象
	Response *ghttp.Response // 返回数据对象(r.Response)
	Server   *ghttp.Server   // Web Server对象(r.Server)
	Cookie   *ghttp.Cookie   // COOKIE操作对象(r.Cookie)
	Session  *ghttp.Session  // SESSION操作对象
	View     *View           // 视图对象
}

控制器基类

func (*Controller) Exit

func (c *Controller) Exit()

推出请求执行

func (*Controller) Init

func (c *Controller) Init(r *ghttp.Request)

控制器初始化接口方法

func (*Controller) Shut

func (c *Controller) Shut(r *ghttp.Request)

控制器结束请求接口方法

type Model

type Model struct {
}

MVC模型基类

type View

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

基于控制器注册的MVC视图基类(一个请求一个视图对象,用完即销毁)

func NewView

func NewView(w *ghttp.Response) *View

创建一个MVC请求中使用的视图对象

func (*View) Assign

func (view *View) Assign(key string, value interface{})

绑定模板变量,即调用之后每个线程都会生效,因此有并发安全控制

func (*View) Assigns

func (view *View) Assigns(data map[string]interface{})

批量绑定模板变量,即调用之后每个线程都会生效,因此有并发安全控制

func (*View) Display

func (view *View) Display(file ...string) error

解析并显示指定模板

func (*View) DisplayContent

func (view *View) DisplayContent(content string) error

解析并显示模板内容

func (*View) LockFunc

func (view *View) LockFunc(f func(vars map[string]interface{}))

使用自定义方法对模板变量执行加锁修改操作

func (*View) Parse

func (view *View) Parse(file string) ([]byte, error)

解析模板,并返回解析后的内容

func (*View) ParseContent

func (view *View) ParseContent(content string) ([]byte, error)

直接解析模板内容,并返回解析后的内容

func (*View) RLockFunc

func (view *View) RLockFunc(f func(vars map[string]interface{}))

使用自定义方法对模板变量执行加锁读取操作

Jump to

Keyboard shortcuts

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