diff --git a/server/app/app.go b/server/app/app.go new file mode 100644 index 0000000..257d316 --- /dev/null +++ b/server/app/app.go @@ -0,0 +1,15 @@ +package app + +import ( + "sirlab.de/go/knyt/engine" + "sirlab.de/go/knyt/handler" +) + +type App struct { + Mux *handler.AuthMux + Eng *engine.Engine +} + +func NewApp() *App { + return &App{} +} diff --git a/server/knyt.go b/server/knyt.go index b6fb893..6c700d4 100644 --- a/server/knyt.go +++ b/server/knyt.go @@ -3,23 +3,25 @@ package main import ( "fmt" "net/http" + "sirlab.de/go/knyt/app" "sirlab.de/go/knyt/engine" "sirlab.de/go/knyt/handler" ) func main() { - app := handler.NewAuthMux() - http.Handle("/", app) + app := app.NewApp() + app.Mux = handler.NewAuthMux() + app.Eng = engine.NewEngine() + http.Handle("/", app.Mux) - app.PublicHandleFunc("/__intern__/exit", handler.Exit) + app.Mux.PublicHandleFunc("/__intern__/exit", handler.Exit) // default handler fsHandler := http.FileServer(http.Dir("../client/dist/")) - app.PublicHandle("/", fsHandler) + app.Mux.PublicHandle("/", fsHandler) - eng := engine.NewEngine() - app.PublicHandleFunc("/api/sync", eng.GetHttpHandler()) - go eng.Run() + app.Mux.PublicHandleFunc("/api/sync", app.Eng.GetHttpHandler()) + go app.Eng.Run() // start listening fmt.Println("http://localhost:32039")