mirror of
https://github.com/fhmq/hmq.git
synced 2026-05-02 14:28:34 +00:00
* Allow Broker DisConnect connections by ClientId * Allow Broker DisConnect connections by ClientId
27 lines
482 B
Go
27 lines
482 B
Go
package broker
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func InitHTTPMoniter(b *Broker) {
|
|
gin.SetMode(gin.ReleaseMode)
|
|
router := gin.Default()
|
|
router.DELETE("api/v1/connections/:clientid", func(c *gin.Context) {
|
|
clientid := c.Param("clientid")
|
|
cli, ok := b.clients.Load(clientid)
|
|
if ok {
|
|
conn, success := cli.(*client)
|
|
if success {
|
|
conn.Close()
|
|
}
|
|
}
|
|
resp := map[string]int{
|
|
"code": 0,
|
|
}
|
|
c.JSON(200, &resp)
|
|
})
|
|
|
|
router.Run(":" + b.config.HTTPPort)
|
|
}
|