1 Star 0 Fork 13

Dapeng / HxGo

forked from 傅小黑 / GoInk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
controller.go 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
package hxgo
// controller object
type Controller struct {
R *Request
Rs *Response
Input *Input
View *View
}
// new controller func
func (this *Controller) New(w *Response, r *Request, v *View) {
this.R = r
this.Rs = w
this.Input = this.R.Input()
this.View = v
}
// init controller func, empty for basic controller struct
func (this *Controller) Init() {
}
// default controller called method
func (this *Controller) Index() {
this.Error(404, "Page Not Found")
}
// controller done
func (this *Controller) Done(content string) {
this.Rs.Content = content
this.Rs.Done()
}
// redirect url
func (this *Controller) Redirect(url string) {
this.Rs.Redirect(url)
}
// display view template and done
func (this *Controller) Display(t string, data map[string]interface {}, nest []string) error {
str, e := this.View.Render(t, data, nest)
if e != nil {
return e
}
this.Done(str)
return nil
}
// do error to error handler
func (this *Controller) Error(status int, message string) {
this.Rs.Error(status, message)
}
// show json response and done
func (this *Controller) Json(data interface {}) error {
return this.Rs.Json(data)
}
1
https://gitee.com/yuanpeng-wang/hxgo.git
git@gitee.com:yuanpeng-wang/hxgo.git
yuanpeng-wang
hxgo
HxGo
master

搜索帮助