Commit ea110516 authored by brent's avatar brent

modify client api

parent a55025c7
...@@ -18,6 +18,8 @@ func kongApi(path string, method string, payload io.Reader, headers map[string]s ...@@ -18,6 +18,8 @@ func kongApi(path string, method string, payload io.Reader, headers map[string]s
url := base_url + "/" + path url := base_url + "/" + path
logs.Debug("kongApi in", url, payload)
reqest, err := http.NewRequest(method, url, payload) reqest, err := http.NewRequest(method, url, payload)
for key, value := range headers { for key, value := range headers {
reqest.Header.Add(key, value) reqest.Header.Add(key, value)
...@@ -25,14 +27,17 @@ func kongApi(path string, method string, payload io.Reader, headers map[string]s ...@@ -25,14 +27,17 @@ func kongApi(path string, method string, payload io.Reader, headers map[string]s
//reqest.Header.Add("Content-Type", "application/json") //reqest.Header.Add("Content-Type", "application/json")
resp, err := client.Do(reqest) resp, err := client.Do(reqest)
if err != nil { if err != nil {
logs.Debug("kongApi err", err.Error())
return nil, err return nil, err
} }
//fmt.Printf("resp status code: %s\n", resp.Body) //fmt.Printf("resp status code: %s\n", resp.Body)
defer resp.Body.Close() defer resp.Body.Close()
body, err := io.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
logs.Debug("kongApi err", err.Error())
return nil, err return nil, err
} }
logs.Debug("kongApi out", url, string(body))
return body, nil return body, nil
} }
......
...@@ -28,6 +28,16 @@ func init() { ...@@ -28,6 +28,16 @@ func init() {
} }
func main() { func main() {
//createUser := models.CreateUserRequest{
// Username: "123",
// CustomId: "2323",
//}
//payload := new(bytes.Buffer)
//json.NewEncoder(payload).Encode(createUser)
//
//logs.Debug("temp = ", payload)
//t := time.Now() //t := time.Now()
//temp := fmt.Sprintf(t.Format("2006-01-02T15:04:05.000000Z")) //temp := fmt.Sprintf(t.Format("2006-01-02T15:04:05.000000Z"))
//logs.Debug("temp = ", temp) //logs.Debug("temp = ", temp)
...@@ -42,10 +52,10 @@ func main() { ...@@ -42,10 +52,10 @@ func main() {
// logs.SetLogger(logs.AdapterFile, config) // logs.SetLogger(logs.AdapterFile, config)
//} //}
str := "2024-02-01T18:41:30" //str := "2024-02-01T18:41:30"
layout := "2006-01-02T15:04:05" //layout := "2006-01-02T15:04:05"
t, _ := time.Parse(layout, str) //t, _ := time.Parse(layout, str)
fmt.Print("t = %s", t) //fmt.Print("t = %s", t)
//currentTime := time.Now() //currentTime := time.Now()
////if appRequest.EndTime == nil { ////if appRequest.EndTime == nil {
//tempendTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, currentTime.Location()) //tempendTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, currentTime.Location())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment