Files
wallet-go-api/pkg/utl/server/server.go
Fran Jurmanović 4076a7b010 display ip
2021-05-25 20:55:37 +02:00

29 lines
430 B
Go

package server
import (
"fmt"
"os"
"wallet-api/pkg/utl/common"
"github.com/gin-gonic/gin"
)
func Start(r *gin.Engine) *gin.Engine {
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
port := os.Getenv("PORT")
if port == "" {
port = "4000"
}
err := r.Run(":" + port)
if err != nil {
msg := fmt.Sprintf("Running on %s:%s", common.GetIP(), port)
println(msg)
}
return r
}