tiamat/cmd/httpServer.go

28 lines
388 B
Go
Raw Normal View History

2024-06-03 09:24:18 +02:00
package cmd
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
)
var (
WebPort string = "8080"
)
func WebServer() {
p := viper.GetString("Server.WebPort")
if p != "" {
WebPort = p
}
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
r.GET("/", getRoot)
r.Run(":" + WebPort)
}
func getRoot(c *gin.Context) {
c.String(http.StatusOK, "Hello world!\n")
}