diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 44 |
1 files changed, 14 insertions, 30 deletions
@@ -1,15 +1,14 @@ package main import ( - "net/http" + "sync" "git.capotej.com/capotej/communique/cgi" "git.capotej.com/capotej/communique/config" + "git.capotej.com/capotej/communique/http" "github.com/BurntSushi/toml" "go.uber.org/zap" "go.uber.org/zap/zapio" - - "github.com/gin-gonic/gin" ) func main() { @@ -26,36 +25,21 @@ func main() { if err != nil { log.Fatal(err) } - log.Debugf("Loaded TOML Config: %+v", cfg) - // Server + var mainWg sync.WaitGroup + + // Internal CGI Servers + cgiServers := cgi.NewServers() + mainWg.Add(1) + go cgiServers.Start(cfg) + + // External Http Server writer := &zapio.Writer{Log: logger, Level: zap.DebugLevel} defer writer.Close() + server := http.NewServer() + mainWg.Add(1) + go server.Start(writer) - // CGI Servers - servers := cgi.NewServers() - // TODO Should probably be in a global waitgroup - go servers.Start(cfg) - - // HTTP Server - router := gin.Default() - router.SetTrustedProxies(nil) - gin.DisableConsoleColor() - gin.DefaultWriter = writer // send gin logs to zap - - router.GET("/ping", func(c *gin.Context) { - c.JSON(http.StatusOK, gin.H{ - "message": "pong", - }) - }) - - // This handler will match /user/john but will not match /user/ or /user - router.GET("/.well-known/webfinger", func(c *gin.Context) { - // resource := c.Query("resource") - c.JSON(http.StatusOK, nil) - }) - - // TODO Should probably be in a global waitgroup - router.Run() + mainWg.Wait() } |