Advertisement
Guest User

testing

a guest
Jun 25th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.59 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "net/http"
  5.  
  6.     "github.com/gin-gonic/gin"
  7.     eztemplate "github.com/michelloworld/ez-gin-template"
  8. )
  9.  
  10. func main() {
  11.     r := gin.Default()
  12.     render := eztemplate.New()
  13.     render.TemplatesDir = "templates"
  14.     render.Layout = "/layouts/base"
  15.     render.Debug = true
  16.     r.HTMLRender = render.Init()
  17.     r.GET("/", func(c *gin.Context) {
  18.         c.JSON(http.StatusOK, gin.H{
  19.             "message": "pong",
  20.         })
  21.     })
  22.     r.GET("/ping", func(c *gin.Context) {
  23.         c.HTML(http.StatusOK, "templates/example.html", gin.H{
  24.             "title": "Main website",
  25.         })
  26.     })
  27.     r.Run() // listen and serve on 0.0.0.0:8080
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement