inital gin code
This commit is contained in:
parent
a000db02ea
commit
1618983416
1 changed files with 30 additions and 4 deletions
34
main.go
34
main.go
|
@ -1,10 +1,36 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/valyala/fasthttp"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hi")
|
||||
func setupRouter() *gin.Engine {
|
||||
// Disable Console Color
|
||||
// gin.DisableConsoleColor()
|
||||
router := gin.Default()
|
||||
|
||||
router.LoadHTMLGlob("templates/*")
|
||||
|
||||
// Ping test
|
||||
router.GET("/ping", func(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"message": "pong",
|
||||
})
|
||||
})
|
||||
|
||||
router.GET("/", func(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "index.html", gin.H{
|
||||
"test": "templating or something",
|
||||
})
|
||||
})
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
func main() {
|
||||
router := setupRouter()
|
||||
// Listen and Server in 0.0.0.0:8080
|
||||
router.Run(":8080")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue