]> git.scottworley.com Git - reliable-chat/blobdiff - server/server.go
Add an id to messages
[reliable-chat] / server / server.go
index a328785aa5375ebfd8693b7cc6e44038a8ccfa45..8ce96787ac89658490ab943dc2b7710db4a38a14 100644 (file)
@@ -18,6 +18,7 @@ var fetch_wake_count = expvar.NewInt("fetch_wake_count")
 
 type Message struct {
        Time time.Time
+       ID   string
        Text string
 }
 
@@ -121,10 +122,13 @@ func start_server(store Store) {
        })
 
        http.HandleFunc("/speak", func(w http.ResponseWriter, r *http.Request) {
-               store.Add <- &Message{time.Now(), r.FormValue("text")}
+               store.Add <- &Message{
+                       time.Now(),
+                       r.FormValue("id"),
+                       r.FormValue("text")}
        })
 
-       log.Fatal(http.ListenAndServe(":" + strconv.Itoa(*port), nil))
+       log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil))
 }
 
 func main() {