Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "net/http"
- "github.com/gin-gonic/gin"
- eztemplate "github.com/michelloworld/ez-gin-template"
- )
- func main() {
- r := gin.Default()
- render := eztemplate.New()
- render.TemplatesDir = "templates"
- render.Layout = "/layouts/base"
- render.Debug = true
- r.HTMLRender = render.Init()
- r.GET("/", func(c *gin.Context) {
- c.JSON(http.StatusOK, gin.H{
- "message": "pong",
- })
- })
- r.GET("/ping", func(c *gin.Context) {
- c.HTML(http.StatusOK, "templates/example.html", gin.H{
- "title": "Main website",
- })
- })
- r.Run() // listen and serve on 0.0.0.0:8080
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement