package main import ( "net/http" "github.com/gin-gonic/gin" ) type Server struct { Addr string Username string Password string } func NewServer(addr, username, password string) *Server { s := &Server{ Addr: serverAddr, Username: serverUsername, Password: serverPassword, } if addr != "" { s.Addr = addr } if username != "" { s.Username = username } if password != "" { s.Password = password } return s } func (s *Server) Run() { r := gin.Default() r.GET("/ping", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "message": "pong", }) }) r.Run(s.Addr) // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") }