chore: 规范化连接地址
This commit is contained in:
parent
93bc5e80c4
commit
e148d8aeda
@ -4,6 +4,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"onvif-agent/service/onvif"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var conns = make(map[string]*onvif.Connection)
|
||||
@ -21,7 +22,13 @@ func CreateConnection(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
conn, err := onvif.NewConnection(req.Xaddr, req.Username, req.Password)
|
||||
// 规范化连接地址
|
||||
xaddr := req.Xaddr
|
||||
if !strings.Contains(xaddr, ":") {
|
||||
xaddr += ":80"
|
||||
}
|
||||
|
||||
conn, err := onvif.NewConnection(xaddr, req.Username, req.Password)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": err.Error(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user