dont need makeit and cleanit.
[goDBhammer.git] / src / webconnector.go
index de43ec6..a25b640 100644 (file)
@@ -8,12 +8,39 @@ import (
        "io";
        //"./dbibridge";
        "./benchcontroller";
+       //"dbconnector";
        "fmt";
+       "json";
 )
 
+type JSONStatData 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;
@@ -50,6 +77,7 @@ func beginPage(c *http.Conn, req *http.Request)
                //dbname := req.FormValue("dbname");
                //nthreads := req.FormValue("nthreads");
                //dbmult := req.FormValue("dbmult");
+               comout <- "begin:setup";
                
                footer(c);
        }
@@ -127,12 +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.HandlerFunc(ServerResponder));
+       http.Handle("/", http.FileServer("./web", "/web"));
+       http.Handle("/json", http.HandlerFunc(JSONResponder));
        err := http.ListenAndServe(":22222", nil);
        if err != nil {
                panic("ListenAndServe: ", err.String())