api_func_ip_post.go 722 B

123456789101112131415161718192021222324252627282930313233
  1. package route
  2. import (
  3. "opennamu/route/tool"
  4. "strconv"
  5. )
  6. func Api_func_ip_post(config tool.Config) string {
  7. db := tool.DB_connect()
  8. defer tool.DB_close(db)
  9. other_set := map[string]string{}
  10. json.Unmarshal([]byte(config.Other_set), &other_set)
  11. ip_data := map[string]string{}
  12. for for_a := 1; ; for_a++ {
  13. for_a_str := strconv.Itoa(for_a)
  14. if val, ok := other_set["data_" + for_a_str]; ok {
  15. ip_data[val] = tool.IP_parser(db, val, config.IP)
  16. } else {
  17. break
  18. }
  19. }
  20. new_data := make(map[string]any)
  21. new_data["response"] = "ok"
  22. new_data["data"] = ip_data
  23. json_data, _ := json.Marshal(new_data)
  24. return string(json_data)
  25. }