2017-12-29 16:03:30 +08:00
|
|
|
// Copyright 2017 gf Author(https://gitee.com/johng/gf). All Rights Reserved.
|
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
|
// You can obtain one at https://gitee.com/johng/gf.
|
|
|
|
|
|
2018-01-03 10:53:45 +08:00
|
|
|
// MVC
|
2017-12-11 17:16:59 +08:00
|
|
|
package gmvc
|
2017-12-08 09:50:11 +08:00
|
|
|
|
2017-12-13 16:45:00 +08:00
|
|
|
import (
|
|
|
|
|
"gitee.com/johng/gf/g/net/ghttp"
|
|
|
|
|
)
|
|
|
|
|
|
2017-12-08 09:50:11 +08:00
|
|
|
// 控制器基类
|
|
|
|
|
type Controller struct {
|
2018-01-02 16:35:13 +08:00
|
|
|
Request *ghttp.Request // 请求数据对象
|
|
|
|
|
Response *ghttp.Response // 返回数据对象(r.Response)
|
|
|
|
|
Server *ghttp.Server // Web Server对象(r.Server)
|
2018-01-08 11:38:31 +08:00
|
|
|
Cookie *ghttp.Cookie // COOKIE操作对象(r.Cookie)
|
2018-01-02 16:35:13 +08:00
|
|
|
Session *ghttp.Session // SESSION操作对象
|
|
|
|
|
View *View // 视图对象
|
2017-12-13 16:45:00 +08:00
|
|
|
}
|
|
|
|
|
|
2017-12-18 10:42:59 +08:00
|
|
|
// 控制器初始化接口方法
|
2018-01-02 15:52:32 +08:00
|
|
|
func (c *Controller) Init(r *ghttp.Request) {
|
2017-12-13 16:45:00 +08:00
|
|
|
c.Request = r
|
2018-01-02 15:52:32 +08:00
|
|
|
c.Response = r.Response
|
2018-01-03 10:23:37 +08:00
|
|
|
c.Server = r.Server
|
2018-01-02 15:52:32 +08:00
|
|
|
c.View = NewView(r.Response)
|
2017-12-31 12:15:04 +08:00
|
|
|
c.Cookie = r.Cookie
|
|
|
|
|
c.Session = r.Session
|
2017-12-08 09:50:11 +08:00
|
|
|
}
|
2017-12-13 16:45:00 +08:00
|
|
|
|
2017-12-18 10:42:59 +08:00
|
|
|
// 控制器结束请求接口方法
|
2018-03-13 17:57:41 +08:00
|
|
|
func (c *Controller) Shut(r *ghttp.Request) {
|
2017-12-30 23:49:55 +08:00
|
|
|
|
2017-12-13 16:45:00 +08:00
|
|
|
}
|
|
|
|
|
|
2018-08-17 19:01:49 +08:00
|
|
|
// 退出请求执行
|
2018-04-16 16:50:24 +08:00
|
|
|
func (c *Controller) Exit() {
|
|
|
|
|
c.Request.Exit()
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-13 16:45:00 +08:00
|
|
|
|