Files
gf/g/frame/gmvc/controller.go

43 lines
1.1 KiB
Go
Raw Normal View History

// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
2017-12-29 16:03:30 +08:00
//
// 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://github.com/gogf/gf.
2017-12-29 16:03:30 +08:00
2019-01-16 09:00:23 +08:00
// Package gmvc provides basic object classes for MVC.
package gmvc
2017-12-08 09:50:11 +08:00
import (
2019-06-19 09:06:52 +08:00
"github.com/gogf/gf/g/net/ghttp"
)
2017-12-08 09:50:11 +08:00
// 控制器基类
type Controller struct {
2019-06-19 09:06:52 +08:00
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 (c *Controller) Init(r *ghttp.Request) {
2019-06-19 09:06:52 +08:00
c.Request = r
c.Response = r.Response
c.Server = r.Server
c.View = NewView(r.Response)
c.Cookie = r.Cookie
c.Session = r.Session
2017-12-08 09:50:11 +08:00
}
// 控制器结束请求接口方法
2018-12-28 21:46:01 +08:00
func (c *Controller) Shut() {
}
2018-08-17 19:01:49 +08:00
// 退出请求执行
2018-04-16 16:50:24 +08:00
func (c *Controller) Exit() {
2019-06-19 09:06:52 +08:00
c.Request.Exit()
2018-04-16 16:50:24 +08:00
}