17 // hello world, the web server
18 func ServerResponder(c *http.Conn, req *http.Request) {
22 fmt.Printf("lk: %s %s %s\n", req.Method, req.RawURL, req.URL);
23 if req.RawURL == "/" {
27 if req.RawURL == "/confirm" {
31 // fucking go, i just wanna consume the incoming data, but it forces me to do something with it... cunt of a language
33 //fmt.Printf("%d\n", k);
36 func confirmPage(c *http.Conn, req *http.Request)
39 io.WriteString(c, "<h1>Confirm</h1>");
40 dbhost := req.FormValue("dbhost");
41 dbuser := req.FormValue("dbuser");
42 dbpass := req.FormValue("dbpass");
43 dbname := req.FormValue("dbname");
44 nthreads := req.FormValue("nthreads");
46 io.WriteString(c, "You are trying to perform a benchmark with the following values:<br>");
47 io.WriteString(c, "<table>");
48 io.WriteString(c, fmt.Sprintf("<tr><td>Host</td><td>%s</td></tr>", dbhost));
49 io.WriteString(c, fmt.Sprintf("<tr><td>User</td><td>%s</td></tr>", dbuser));
50 io.WriteString(c, fmt.Sprintf("<tr><td>Password</td><td>%s</td></tr>", dbpass));
51 io.WriteString(c, fmt.Sprintf("<tr><td>Database</td><td>%s</td></tr>", dbname));
52 io.WriteString(c, fmt.Sprintf("<tr><td>Number of Threads</td><td>%s</td></tr>", nthreads));
53 io.WriteString(c, "</table>");
54 io.WriteString(c, "<a href=\"/\">Back</a>");
55 io.WriteString(c, fmt.Sprintf(" <a href=\"/start?host=%s&user=%s&pass=%s&db=%s&nt=%s\">Begin</a>", dbhost, dbuser, dbpass, dbname, nthreads));
60 func mainPage(c *http.Conn, req *http.Request)
63 io.WriteString(c, "<h1>goDBHammer</h1><br>");
64 io.WriteString(c, "Welcome to goDBHammer, the go based database benchmarking tool<br>");
65 io.WriteString(c, "<form method=\"post\" action=\"/confirm\">");
66 io.WriteString(c, "<table><tr><td>Database Type</td><td><input type=\"text\" name=\"dbtype\" value=\"ignored for now\"></td></tr>");
67 io.WriteString(c, "<tr><td>Database Host</td><td><input type=\"text\" name=\"dbhost\"></td></tr>");
68 io.WriteString(c, "<tr><td>Database User</td><td><input type=\"text\" name=\"dbuser\"></td></tr>");
69 io.WriteString(c, "<tr><td>Database Password</td><td><input type=\"text\" name=\"dbpass\"></td></tr>");
70 io.WriteString(c, "<tr><td>Database</td><td><input type=\"text\" name=\"dbname\"></td></tr>");
71 io.WriteString(c, "<tr><td>Number of Clients</td><td><input type=\"text\" name=\"nthreads\"></td></tr>");
72 io.WriteString(c, "<tr><td><input type=\"submit\" name=\"Setup\" value=\"Setup\"></td></tr>");
73 io.WriteString(c, "</table>");
74 io.WriteString(c, "</form>");
75 fmt.Printf("%s\n", req.FormValue("dbhost"));
79 func header(c *http.Conn)
81 io.WriteString(c, "<html><head></head><body>");
84 func footer(c *http.Conn)
86 io.WriteString(c, "</body></html>");
91 comin = make(chan int);
92 comout = make(chan int);
94 bc := benchcontroller.CreateController();
95 go benchcontroller.MainLoop(bc, comout, comin);
97 http.Handle("/", http.HandlerFunc(ServerResponder));
98 err := http.ListenAndServe(":12345", nil);
100 panic("ListenAndServe: ", err.String())