package main import ( "fmt" "github.com/imkira/go-observer" "net/http" "sirlab.de/go/knyc/handler" "time" ) type Engine struct { obs observer.Property } var engine Engine func (engine Engine) runEngine() { for { value := engine.obs.Value().(handler.Value) fmt.Printf("sleep: %d\n", value.Value) time.Sleep(1 * time.Second) value.Value++ engine.obs.Update(value) } } func main() { app := handler.NewAuthMux() http.Handle("/", app) app.PublicHandleFunc("/__intern__/exit", handler.Exit) obs := observer.NewProperty(handler.Value{Value: 19}) app.PublicHandleFunc("/sync", handler.SyncFactory(obs)) // hanlde login page fsHandler := http.FileServer(http.Dir("../client/dist/")) // default handler app.PublicHandle("/", fsHandler) engine.obs = obs go engine.runEngine() // start listening fmt.Println("http://localhost:32039") http.ListenAndServe(":32039", nil) }