ParseRequestData eg. "trustfile":"test:1,test2:2"

    xiaoxiao2022-07-02  113

    //ParseRequestData parse libdir trustfile eg. "trustfile":"test:1,test2:2" func ParseRequestData(mapdata map[string]string, input string) bool {     if !govalidator.IsNull(input) {         if strings.Count(input, ":") == strings.Count(input, ",")+1 {             sdata := strings.Split(input, ",")             for _, n := range sdata {                 if !govalidator.IsNull(n) {                     ndata := strings.Split(n, ":")                     mapdata[ndata[0]] = ndata[1]                 } else {                     return false                 }             }         } else {             return false         }     }     return true }     // trustfile {"test1:test1, test2:test2"}     // libdirmapdata := make(map[string]string)     // trustfilemapdata := make(map[string]string)     // if !ParseRequestData(libdirmapdata, libdir) {     //  return "", errno.ErrRequestData.Add(libdir)     // }     // if !ParseRequestData(trustfilemapdata, trustfile) {     //  return "", errno.ErrRequestData.Add(trustfile)     // }

     

    最新回复(0)