mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-11-29 02:42:51 +00:00
try fix err with nil in body
This commit is contained in:
parent
0a6e02cf18
commit
d3865bf4d1
2 changed files with 13 additions and 4 deletions
|
|
@ -13,7 +13,6 @@ import (
|
|||
"github.com/mhsanaei/3x-ui/v2/web/session"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
)
|
||||
|
||||
// InboundController handles HTTP requests related to Xray inbounds management.
|
||||
|
|
@ -123,8 +122,7 @@ func (a *InboundController) addInbound(c *gin.Context) {
|
|||
c.Request.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
|
||||
|
||||
inbound := &model.Inbound{}
|
||||
err := c.ShouldBindWith(inbound, binding.Form)
|
||||
// err := c.ShouldBind(inbound)
|
||||
err := c.ShouldBind(inbound)
|
||||
if err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -2460,8 +2460,19 @@ func (s *InboundService) syncWithSlaves(method string, path string, contentType
|
|||
continue
|
||||
}
|
||||
for key, value := range tmp {
|
||||
if value == nil { // skip nil fields
|
||||
continue
|
||||
}
|
||||
|
||||
// if the field is a slice or a map, marshal it to JSON
|
||||
switch vv := value.(type) {
|
||||
case map[string]interface{}, []interface{}:
|
||||
jsonVal, _ := json.Marshal(vv)
|
||||
form.Set(key, string(jsonVal))
|
||||
default:
|
||||
form.Set(key, fmt.Sprintf("%v", value))
|
||||
}
|
||||
}
|
||||
default:
|
||||
logger.Warningf("Unsupported body type: %T for form encoding on server %s", v, server.Name)
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in a new issue