mirror of https://gitee.com/topnuomi/goweb
30 lines
563 B
Go
30 lines
563 B
Go
package home
|
|
|
|
import (
|
|
"net/http"
|
|
"site/app/middlewares"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type IndexController struct{}
|
|
|
|
func NewIndexController() *IndexController {
|
|
return &IndexController{}
|
|
}
|
|
|
|
func (ic *IndexController) Register(rg *gin.RouterGroup) {
|
|
rg.GET("/", middlewares.Auth(), ic.Index)
|
|
rg.GET("/about", ic.About)
|
|
}
|
|
|
|
func (ic *IndexController) Index(c *gin.Context) {
|
|
c.JSON(http.StatusOK, gin.H{"data": "HelloWorld!"})
|
|
}
|
|
|
|
func (ic *IndexController) About(c *gin.Context) {
|
|
c.HTML(http.StatusOK, "home/about.html", gin.H{
|
|
"title": "About",
|
|
})
|
|
}
|