aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2022-12-17 20:22:52 +0000
committerJulio Capote <jcapote@gmail.com>2022-12-17 20:22:52 +0000
commit2585e05af116cb95d2d2c36b096345c2b982e39c (patch)
treed0db377bd9465d4d74db60e6969abf6987a4c81c /main.go
parent0f01fc1004122e18f5320f28db63830666a4c8be (diff)
downloadcommunique-2585e05af116cb95d2d2c36b096345c2b982e39c.tar.gz
refactor
Diffstat (limited to '')
-rw-r--r--main.go44
1 files changed, 14 insertions, 30 deletions
diff --git a/main.go b/main.go
index 195e02d..5935bc9 100644
--- a/main.go
+++ b/main.go
@@ -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()
}