From 4797530476e7d7e9a21abd4386043ea46a38963e Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Tue, 26 May 2015 12:15:43 +0200 Subject: [PATCH] Fixes example code --- examples/realtime-advanced/routes.go | 12 ++++++------ examples/realtime-chat/main.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/realtime-advanced/routes.go b/examples/realtime-advanced/routes.go index 4ac95aa..b187756 100644 --- a/examples/realtime-advanced/routes.go +++ b/examples/realtime-advanced/routes.go @@ -31,8 +31,8 @@ func index(c *gin.Context) { } func roomGET(c *gin.Context) { - roomid := c.ParamValue("roomid") - nick := c.FormValue("nick") + roomid := c.Param("roomid") + nick := c.Query("nick") if len(nick) < 2 { nick = "" } @@ -48,9 +48,9 @@ func roomGET(c *gin.Context) { } func roomPOST(c *gin.Context) { - roomid := c.ParamValue("roomid") - nick := c.FormValue("nick") - message := c.PostFormValue("message") + roomid := c.Param("roomid") + nick := c.Query("nick") + message := c.PostForm("message") message = strings.TrimSpace(message) validMessage := len(message) > 1 && len(message) < 200 @@ -73,7 +73,7 @@ func roomPOST(c *gin.Context) { } func streamRoom(c *gin.Context) { - roomid := c.ParamValue("roomid") + roomid := c.Param("roomid") listener := openListener(roomid) ticker := time.NewTicker(1 * time.Second) users.Add("connected", 1) diff --git a/examples/realtime-chat/main.go b/examples/realtime-chat/main.go index 4eb5e50..e4b55a0 100644 --- a/examples/realtime-chat/main.go +++ b/examples/realtime-chat/main.go @@ -21,7 +21,7 @@ func main() { } func stream(c *gin.Context) { - roomid := c.ParamValue("roomid") + roomid := c.Param("roomid") listener := openListener(roomid) defer closeListener(roomid, listener) @@ -32,7 +32,7 @@ func stream(c *gin.Context) { } func roomGET(c *gin.Context) { - roomid := c.ParamValue("roomid") + roomid := c.Param("roomid") userid := fmt.Sprint(rand.Int31()) c.HTML(200, "chat_room", gin.H{ "roomid": roomid, @@ -41,9 +41,9 @@ func roomGET(c *gin.Context) { } func roomPOST(c *gin.Context) { - roomid := c.ParamValue("roomid") - userid := c.PostFormValue("user") - message := c.PostFormValue("message") + roomid := c.Param("roomid") + userid := c.PostForm("user") + message := c.PostForm("message") room(roomid).Submit(userid + ": " + message) c.JSON(200, gin.H{ @@ -53,6 +53,6 @@ func roomPOST(c *gin.Context) { } func roomDELETE(c *gin.Context) { - roomid := c.ParamValue("roomid") + roomid := c.Param("roomid") deleteBroadcast(roomid) }