基本定义
一段控制器的Build函数
func(this *IndexController) Build(goft *goft.Goft){
goft.Handle("GET","/",this.Index).
HandleWithFairing("GET","/test",
this.IndexTest,
middlewares.NewIndexTest())
}type IndexTest struct {
}
func NewIndexTest() *IndexTest {
return &IndexTest{}
}
func(this *IndexTest) OnRequest(ctx *gin.Context) error{
return nil
}
func(this *IndexTest) OnResponse(result interface{}) (interface{}, error){
if m,ok:=result.(gin.H);ok{
m["metadata"]="index test"
return m,nil
}
return result,nil
}最后更新于