X-Git-Url: http://git.pjr.cc/?p=goDBhammer.git;a=blobdiff_plain;f=src%2Fwebconnector.go;h=4b7b60b156f9dd9b4d36f45ee9a938ed4e293df7;hp=fa814f3badd0bbf43c16150c697f2fd0a5546b44;hb=deb9dc585d6bb170f01e98db00ad6ea70f0b4ef7;hpb=947aefe43247ed8a2331ccc951dc4763008a151a diff --git a/src/webconnector.go b/src/webconnector.go index fa814f3..4b7b60b 100644 --- a/src/webconnector.go +++ b/src/webconnector.go @@ -10,11 +10,37 @@ import ( "./benchcontroller"; //"dbconnector"; "fmt"; + "json"; ) +type JSONdata struct { + currentJob int; // 1 = nothing, 2 = have database login, 3 = createing data, 4 = running test, 5 = finished + currentStatus int; // percent complete +} + var comin chan string; +var cominstatus chan string; var comout chan string; +func JSONResponder(c *http.Conn, req *http.Request) +{ + //stat := <- cominstatus; + + j, _, _ := json.StringToJson("{\"somestring\":\"somevalue\"}"); + + io.WriteString(c, fmt.Sprintf("%s\n", json.JsonToString(j))); + + /*if ret { + fmt.Printf("err was true\n"); + } else { + fmt.Printf("err was false\n"); + }*/ + + //fmt.Printf("errto %s\n", errto); + +} + + // hello world, the web server func ServerResponder(c *http.Conn, req *http.Request) { //comout <- 2; @@ -129,14 +155,15 @@ func footer(c *http.Conn) func main() { comin = make(chan string); + cominstatus = make(chan string); comout = make(chan string); bc := benchcontroller.CreateController(); - go benchcontroller.MainLoop(bc, comout, comin); + go benchcontroller.MainLoop(bc, comout, comin, cominstatus); http.Handle("/", http.FileServer("./web", "/web")); - http.Handle("/json", http.HandlerFunc(ServerResponder)); + http.Handle("/json", http.HandlerFunc(JSONResponder)); err := http.ListenAndServe(":22222", nil); if err != nil { panic("ListenAndServe: ", err.String())