github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/test/test_apps/test_go_app/test_go_app.go (about) 1 package main 2 3 import ( 4 "github.com/gin-gonic/gin" 5 "io/ioutil" 6 "log" 7 "os" 8 "path/filepath" 9 ) 10 11 func main() { 12 r := gin.Default() 13 r.GET("/ping_test", func(c *gin.Context) { 14 c.JSON(200, gin.H{ 15 "message": "pong", 16 }) 17 }) 18 r.GET("/env_test", func(c *gin.Context) { 19 c.JSON(200, gin.H{ 20 "message": os.Getenv("KEY"), 21 }) 22 }) 23 r.GET("/mount_test", func(c *gin.Context) { 24 data, err := ioutil.ReadFile(filepath.Join("/data", "data.txt")) 25 if err != nil { 26 log.Printf("mounts_test error: %v", err) 27 c.Error(err) 28 } 29 c.JSON(200, gin.H{ 30 "message": string(data), 31 }) 32 }) 33 r.Run(":8080") // listen and server on 0.0.0.0:8080 34 }