Skip to content

Commit

Permalink
Fixes example code
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed May 26, 2015
1 parent a7e0d4b commit 04f712e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions realtime-advanced/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
}
Expand All @@ -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
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions realtime-chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
Expand All @@ -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{
Expand All @@ -53,6 +53,6 @@ func roomPOST(c *gin.Context) {
}

func roomDELETE(c *gin.Context) {
roomid := c.ParamValue("roomid")
roomid := c.Param("roomid")
deleteBroadcast(roomid)
}

0 comments on commit 04f712e

Please sign in to comment.