refactoring
This commit is contained in:
parent
8bee534e60
commit
3efbb82b88
15
server/app/app.go
Normal file
15
server/app/app.go
Normal file
@ -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{}
|
||||
}
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user