ok, web post is now working through javascript
[goDBhammer.git] / src / webconnector.go
index 127d168..3216db3 100644 (file)
@@ -22,13 +22,15 @@ var comin chan string;
 var cominstatus chan string;
 var comout chan string;
 
+var stat int;
+
 func JSONResponder(c *http.Conn, req *http.Request)
 {
        //stat := <- cominstatus;
        
        if(req.Method == "GET") {
        
-               j, _, _ := json.StringToJson("{\"status\":1, \"complete\":90}");
+               j, _, _ := json.StringToJson(fmt.Sprintf("{\"status\":%d, \"complete\":90}", stat));
                
                io.WriteString(c, fmt.Sprintf("%s\n", json.JsonToString(j)));
                fmt.Printf("i got a get\n");
@@ -37,7 +39,8 @@ func JSONResponder(c *http.Conn, req *http.Request)
                lp := make([]byte, 1048576);
                req.Body.Read(lp);
                fmt.Printf("i got a post...%s\n", (string)(lp));
-               http.Redirect(c, "/", 301);
+               //http.Redirect(c, "/", 301);
+               stat = 2;
        }
        
 }
@@ -59,6 +62,7 @@ func main()
        cominstatus = make(chan string);
        comout = make(chan string);
        
+       stat = 1;
        
        bc := benchcontroller.CreateController();
        go benchcontroller.MainLoop(bc, comout, comin, cominstatus);