testing channels and goroutines.
[goDBhammer.git] / src / webconnector.go
1 // im a web connector
2
3 package main
4
5
6 import (
7         "http";
8         "io";
9         //"./dbibridge";
10         "./benchcontroller";
11         "fmt";
12 )
13
14 var comin chan int;
15 var comout chan int;
16
17 // hello world, the web server
18 func HelloServer(c *http.Conn, req *http.Request) {
19         comout <- 1;
20         io.WriteString(c, "<html><form method=post><input type=\"input\"><input type=\"submit\" name=\"go\" value=\"go\"></html>\n");
21         
22         // fucking go, i just wanna consume the incoming data, but it forces me to do something with it... cunt of a language
23         k := <- comin;
24         fmt.Printf("%d\n", k);
25 }
26
27 func main() {
28
29         //var Dbconn *dbibridge.DBIConnection;
30         
31         //Dbconn = dbibridge.DBICreate();
32         
33         //dbibridge.DBIConnect(Dbconn, "mysql", "localhost", "root", "password", "zm");
34         //dbibridge.ExecSQL(Dbconn, "create table asdf (asdf int)");
35         //dbibridge.DBIDisconnect(Dbconn);
36         
37         comin = make(chan int);
38         comout = make(chan int);
39         
40         bc := benchcontroller.CreateController();
41         go benchcontroller.MainLoop(bc, comout, comin);
42         
43         http.Handle("/hello", http.HandlerFunc(HelloServer));
44         err := http.ListenAndServe(":12345", nil);
45         if err != nil {
46                 panic("ListenAndServe: ", err.String())
47         }
48
49 }