mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
enhance: show the form error details of Preference
This commit is contained in:
parent
b0a3989ef4
commit
398eea2159
8 changed files with 74 additions and 22 deletions
|
@ -38,18 +38,18 @@ func BindAndValid(c *gin.Context, target interface{}) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
t := reflect.TypeOf(target)
|
||||
t := reflect.TypeOf(target).Elem()
|
||||
errorsMap := make(map[string]interface{})
|
||||
for _, value := range verrs {
|
||||
var path []string
|
||||
|
||||
namespace := strings.Split(value.StructNamespace(), ".")
|
||||
|
||||
if t.Name() == "" && len(namespace) > 1 {
|
||||
logger.Debug(t.Name(), namespace)
|
||||
if t.Name() != "" && len(namespace) > 1 {
|
||||
namespace = namespace[1:]
|
||||
}
|
||||
|
||||
getJsonPath(t.Elem(), namespace, &path)
|
||||
getJsonPath(t, namespace, &path)
|
||||
insertError(errorsMap, path, value.Tag())
|
||||
}
|
||||
|
||||
|
|
|
@ -87,9 +87,11 @@ type certJson struct {
|
|||
|
||||
func AddCert(c *gin.Context) {
|
||||
var json certJson
|
||||
|
||||
if !api.BindAndValid(c, &json) {
|
||||
return
|
||||
}
|
||||
|
||||
certModel := &model.Cert{
|
||||
Name: json.Name,
|
||||
SSLCertificatePath: json.SSLCertificatePath,
|
||||
|
|
|
@ -27,7 +27,6 @@ func SaveSettings(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// todo: omit protected fields when binding
|
||||
fillSettings(&settings.ServerSettings, &json.Server)
|
||||
fillSettings(&settings.NginxSettings, &json.Nginx)
|
||||
fillSettings(&settings.OpenAISettings, &json.Openai)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue