forked from mirror/gin
Fixes example code
This commit is contained in:
parent
d209329891
commit
4797530476
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue