"fmt";
)
-var comin chan int;
-var comout chan int;
+var comin chan string;
+var comout chan string;
// hello world, the web server
func ServerResponder(c *http.Conn, req *http.Request) {
if req.RawURL == "/confirm" {
confirmPage(c, req);
}
+
+ if req.RawURL == "/begin" {
+ beginPage(c, req);
+ }
- // fucking go, i just wanna consume the incoming data, but it forces me to do something with it... cunt of a language
//k := <- comin;
//fmt.Printf("%d\n", k);
}
+func beginPage(c *http.Conn, req *http.Request)
+{
+
+ if req.Method != "GET" {
+ http.Redirect(c, "/begin", 301);
+ } else {
+ header(c);
+ io.WriteString(c, "<h1>Starting hammer</h1>");
+ //dbhost := req.FormValue("dbhost");
+ //dbuser := req.FormValue("dbuser");
+ //dbpass := req.FormValue("dbpass");
+ //dbname := req.FormValue("dbname");
+ //nthreads := req.FormValue("nthreads");
+ //dbmult := req.FormValue("dbmult");
+
+ footer(c);
+ }
+
+}
+
func confirmPage(c *http.Conn, req *http.Request)
{
header(c);
dbname := req.FormValue("dbname");
nthreads := req.FormValue("nthreads");
dbmult := req.FormValue("dbmult");
+ var dbtype string;
io.WriteString(c, "You are trying to perform a benchmark with the following values:<br>");
io.WriteString(c, "<table border=\"1\">");
io.WriteString(c, "<input type=\"submit\" name=\"Begin\" value=\"Begin\">");
io.WriteString(c, "</form>");
+ dbtype = "mysql";
+
footer(c);
+ comout <- fmt.Sprintf("configure:%s:%s:%s:%s:%s:%s:%s", dbtype, dbhost, dbuser, dbpass, dbname, dbmult, nthreads);
+
}
func mainPage(c *http.Conn, req *http.Request)
func main()
{
- comin = make(chan int);
- comout = make(chan int);
+ comin = make(chan string);
+ comout = make(chan string);
bc := benchcontroller.CreateController();
go benchcontroller.MainLoop(bc, comout, comin);
http.Handle("/", http.HandlerFunc(ServerResponder));
- err := http.ListenAndServe(":12345", nil);
+ err := http.ListenAndServe(":22222", nil);
if err != nil {
panic("ListenAndServe: ", err.String())
}