31 lines
525 B
Go
31 lines
525 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()
|
||
|
|
||
|
// 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)
|
||
|
}
|
||
|
}
|