1 package main 2 3 import ( 4 "github.com/gin-gonic/contrib/static" 5 "github.com/gin-gonic/gin" 6 ) 7 8 func main() { 9 r := gin.Default() 10 11 // if Allow DirectoryIndex 12 //r.Use(static.Serve("/", static.LocalFile("/tmp", true))) 13 // set prefix 14 //r.Use(static.Serve("/static", static.LocalFile("/tmp", true))) 15 16 r.Use(static.Serve("/", static.LocalFile("/tmp", false))) 17 r.GET("/ping", func(c *gin.Context) { 18 c.String(200, "test") 19 }) 20 // Listen and Server in 0.0.0.0:8080 21 r.Run(":8080") 22 } 23