diff --git a/examples/realtime-advanced/routes.go b/examples/realtime-advanced/routes.go index 4ac95aa0..b1877565 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 4eb5e502..e4b55a0f 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) }