diff --git a/backend/goserver/goserver b/backend/goserver/goserver index f11273b..47b7f90 100755 Binary files a/backend/goserver/goserver and b/backend/goserver/goserver differ diff --git a/backend/goserver/main.go b/backend/goserver/main.go index 9ff66c1..47d3a8e 100644 --- a/backend/goserver/main.go +++ b/backend/goserver/main.go @@ -1,80 +1,85 @@ package main import ( "encoding/json" "fmt" "io/ioutil" sw "kritaServers/backend/goserver/server" "net/http" "time" ) type ColorGroup struct { ID int Name string Colors []string } func handlerInstall(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) fmt.Printf("REQUEST") bodyBuffer, _ := ioutil.ReadAll(r.Body) // fmt.Printf("after parse") //fmt.Println(string(bodyBuffer)) sw.InsertGeneralInfo(bodyBuffer) } func handlerTools(w http.ResponseWriter, r *http.Request) { bodyBuffer, _ := ioutil.ReadAll(r.Body) //fmt.Println(string(bodyBuffer)) sw.InsertToolInfo(bodyBuffer) } func handlerImageProperties(w http.ResponseWriter, r *http.Request) { bodyBuffer, _ := ioutil.ReadAll(r.Body) //fmt.Println(string(bodyBuffer)) sw.InsertImageInfo(bodyBuffer) } func handlerAsserts(w http.ResponseWriter, r *http.Request) { bodyBuffer, _ := ioutil.ReadAll(r.Body) fmt.Printf("Asserts") fmt.Println(string(bodyBuffer)) // sw.InsertAssertInfo(bodyBuffer) } func handlerAgregatedData(w http.ResponseWriter, r *http.Request) { dataType := r.URL.Query().Get("datatype") result, err := json.Marshal(sw.GetAgregatedData(dataType)) sw.CheckErr(err) w.Write(result) } func handlerActions(w http.ResponseWriter, r *http.Request) { bodyBuffer, _ := ioutil.ReadAll(r.Body) //fmt.Println(string(bodyBuffer)) sw.InsertActionInfo(bodyBuffer) } +func handlerHello(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello!!") +} func main() { fmt.Printf("hello") sw.InitDB() defer sw.Session.Close() http.HandleFunc("/install/receiver/submit/org.krita.krita/", handlerInstall) http.HandleFunc("/tools/receiver/submit/org.krita.krita/", handlerTools) http.HandleFunc("/imageProperties/receiver/submit/org.krita.krita/", handlerImageProperties) http.HandleFunc("/asserts/receiver/submit/org.krita.krita/", handlerAsserts) http.HandleFunc("/actions/receiver/submit/org.krita.krita/", handlerActions) http.HandleFunc("/agregatedData", handlerAgregatedData) http.HandleFunc("/GoogleLogin", sw.HandleGoogleLogin) http.HandleFunc("/GoogleCallback", sw.HandleGoogleCallback) + http.HandleFunc("/", handlerHello) + ticker := time.NewTicker(time.Hour * 1) go func() { for t := range ticker.C { sw.AgregateInstalInfo() fmt.Println("Tick at", t) } }() http.ListenAndServe(":8080", nil) }