patchman/server/main.go

32 lines
553 B
Go

package main
import (
"fmt"
"git.jmbit.de/jmb/patchman/server/api"
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
"log"
"net/http"
)
func setupRouter() *gin.Engine {
router := gin.Default()
router.Use(gin.Recovery())
// Ping test
router.GET("/ping", func(c *gin.Context) {
c.String(http.StatusOK, "pong\n")
})
return router
}
func main() {
loadConfig()
router := setupRouter()
router = api.GroupV0(router)
err := router.Run(fmt.Sprintf("%s:%d", viper.Get("address"), viper.Get("port")))
if err != nil {
log.Fatal(err)
}
}