models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseContext added in v0.0.2

type BaseContext struct {
	base.ContextInterface
}

上下文对象

type BaseController added in v0.0.2

type BaseController struct {
	base.ControllerInterface
	// contains filtered or unexported fields
}

所有 handler 的基类。主要处理问题是:统一接口、数据库管理

func (*BaseController) AddValue added in v0.0.2

func (controller *BaseController) AddValue(key string, value interface{})

OVERWRITE: 添加参数

func (*BaseController) AfterAction added in v0.0.2

func (controller *BaseController) AfterAction(action string, response []byte) []byte

执行动作后执行的方法 过滤返回结果

func (*BaseController) BeforeAction added in v0.0.2

func (controller *BaseController) BeforeAction(action string) bool

执行动作前执行的方法 如果返回 false 将会返回一个错误

func (*BaseController) GetContext added in v0.0.2

func (controller *BaseController) GetContext() base.ContextInterface

获取上下文对象

func (*BaseController) GetValue added in v0.0.2

func (controller *BaseController) GetValue(key string) interface{}

获取参数

func (*BaseController) Init added in v0.0.2

func (controller *BaseController) Init()

初始化

func (*BaseController) SetContext added in v0.0.2

func (controller *BaseController) SetContext(context base.ContextInterface)

设置上下文对象

func (*BaseController) SetHttpValues added in v0.0.2

func (controller *BaseController) SetHttpValues(w http.ResponseWriter, r *http.Request)

设置http接收到的参数

func (*BaseController) SetValues added in v0.0.2

func (controller *BaseController) SetValues(values map[string]interface{})

设置接收到的参数

type BaseModel

type BaseModel struct {
}

type Config

type Config struct {
	BaseModel
	Params        map[string]interface{}                   // 参数。自定义的配置参数
	ComponentDict map[string]base.ConfigComponentInterface // 组件。组件名 => 配置
}

配置实例。用于封装配置

func (*Config) Init

func (config *Config) Init()

初始化数据

type Context added in v0.0.2

type Context struct {
	BaseContext
	// contains filtered or unexported fields
}

http 上下文对象

func NewContext added in v0.0.2

func NewContext(session base.SessionInterface) *Context

新建 http 上下文对象

func (*Context) GetSession added in v0.0.2

func (model *Context) GetSession() base.SessionInterface

获取session

type HttpSession added in v0.0.2

type HttpSession struct {
	base.SessionInterface
	// contains filtered or unexported fields
}

session

func NewHttpSession added in v0.0.2

func NewHttpSession(session *sessions.Session) *HttpSession

func (*HttpSession) Destroy added in v0.0.2

func (model *HttpSession) Destroy()

销毁session 清空 session 所有数据

func (*HttpSession) Get added in v0.0.2

func (model *HttpSession) Get(key interface{}) interface{}

获取值

func (*HttpSession) GetSessionId added in v0.0.2

func (model *HttpSession) GetSessionId() string

获取 sessionId

func (*HttpSession) Set added in v0.0.2

func (model *HttpSession) Set(key interface{}, value interface{})

设置值

type MessageModel added in v0.0.2

type MessageModel struct {
	BaseModel
	Id    int64  `json:"i"` // 协议号
	Route string `json:"r"` // 路由
	Data  string `json:"d"` // 传输的数据
}

func (*MessageModel) Validate added in v0.0.2

func (model *MessageModel) Validate() bool

验证数据是否合法

type ResponseModel added in v0.0.2

type ResponseModel struct {
	Code    int                    `json:"c"` // 状态码
	Message string                 `json:"m"` // 消息
	Values  map[string]interface{} `json:"v"` // 传输的值
}

type WebsocketSession

type WebsocketSession struct {
	BaseModel
	// contains filtered or unexported fields
}

websocket 使用的 session 。没有发送的功能。必须依赖 WebsocketServer 进行发送

func NewWebsocketSession

func NewWebsocketSession(conn *websocket.Conn) *WebsocketSession

新建websocket session

func (*WebsocketSession) Destroy added in v0.0.2

func (model *WebsocketSession) Destroy()

销毁session 清空 session 所有数据

func (*WebsocketSession) Get added in v0.0.2

func (model *WebsocketSession) Get(key interface{}) interface{}

获取值

func (*WebsocketSession) GetSessionId added in v0.0.2

func (model *WebsocketSession) GetSessionId() string

获取 sessionId

func (*WebsocketSession) Set added in v0.0.2

func (model *WebsocketSession) Set(key interface{}, value interface{})

设置值

Jump to

Keyboard shortcuts

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