gf/frame/gmvc/controller.go

43 lines
1.0 KiB
Go
Raw Normal View History

2021-01-17 21:46:25 +08:00
// Copyright GoFrame Author(https://goframe.org). 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-07-29 21:01:19 +08:00
"github.com/gogf/gf/net/ghttp"
)
// Controller is used for controller register of ghttp.Server.
2017-12-08 09:50:11 +08:00
type Controller struct {
Request *ghttp.Request
Response *ghttp.Response
Server *ghttp.Server
Cookie *ghttp.Cookie
Session *ghttp.Session
View *View
}
// Init is the callback function for each request initialization.
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
}
// Shut is the callback function for each request close.
2018-12-28 21:46:01 +08:00
func (c *Controller) Shut() {
}
// Exit equals to function Request.Exit().
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
}