api_func_ip_post.go 743 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package route
  2. import (
  3. "strconv"
  4. "opennamu/route/tool"
  5. jsoniter "github.com/json-iterator/go"
  6. )
  7. func Api_func_ip_post(call_arg []string) string {
  8. var json = jsoniter.ConfigCompatibleWithStandardLibrary
  9. other_set := map[string]string{}
  10. json.Unmarshal([]byte(call_arg[0]), &other_set)
  11. db := tool.DB_connect()
  12. defer db.Close()
  13. ip_data := map[string]string{}
  14. for for_a := 1; ; for_a++ {
  15. for_a_str := strconv.Itoa(for_a)
  16. if val, ok := other_set["data_"+for_a_str]; ok {
  17. ip_data[val] = tool.IP_parser(db, val, other_set["ip"])
  18. } else {
  19. break
  20. }
  21. }
  22. new_data := make(map[string]interface{})
  23. new_data["response"] = "ok"
  24. new_data["data"] = ip_data
  25. json_data, _ := json.Marshal(new_data)
  26. return string(json_data)
  27. }