Skip to content

Commit e1222c4

Browse files
committedMay 18, 2018
Fix duplicate port in info
1 parent db13181 commit e1222c4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed
 

‎info.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
package main
22

33
import (
4+
"strings"
5+
46
"github.com/gin-gonic/gin"
57
"go.bug.st/serial.v1"
68
)
79

810
func infoHandler(c *gin.Context) {
11+
host := c.Request.Host
12+
parts := strings.Split(host, ":")
13+
host = parts[0]
14+
915
c.JSON(200, gin.H{
1016
"version": version,
11-
"http": "http://" + c.Request.Host + ":" + port,
12-
"https": "https://" + c.Request.Host + ":" + portSSL,
13-
"ws": "ws://" + c.Request.Host + ":" + port,
14-
"wss": "wss://" + c.Request.Host + ":" + portSSL,
17+
"http": "http://" + host + port,
18+
"https": "https://" + host + portSSL,
19+
"ws": "ws://" + host + port,
20+
"wss": "wss://" + host + portSSL,
1521
})
1622
}
1723

0 commit comments

Comments
 (0)
Please sign in to comment.