github.com/zhongdalu/gf@v1.0.0/g/frame/gmvc/controller.go (about) 1 // Copyright 2017 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/zhongdalu/gf. 6 7 // Package gmvc provides basic object classes for MVC. 8 package gmvc 9 10 import ( 11 "github.com/zhongdalu/gf/g/net/ghttp" 12 ) 13 14 // 控制器基类 15 type Controller struct { 16 Request *ghttp.Request // 请求数据对象 17 Response *ghttp.Response // 返回数据对象(r.Response) 18 Server *ghttp.Server // Web Server对象(r.Server) 19 Cookie *ghttp.Cookie // COOKIE操作对象(r.Cookie) 20 Session *ghttp.Session // SESSION操作对象 21 View *View // 视图对象 22 } 23 24 // 控制器初始化接口方法 25 func (c *Controller) Init(r *ghttp.Request) { 26 c.Request = r 27 c.Response = r.Response 28 c.Server = r.Server 29 c.View = NewView(r.Response) 30 c.Cookie = r.Cookie 31 c.Session = r.Session 32 } 33 34 // 控制器结束请求接口方法 35 func (c *Controller) Shut() { 36 37 } 38 39 // 退出请求执行 40 func (c *Controller) Exit() { 41 c.Request.Exit() 42 }