response format
(resp *http.Response)
| 381 | |
| 382 | // response format |
| 383 | func parsingResponse(resp *http.Response) (string, error) { |
| 384 | if resp == nil { |
| 385 | return "", errors.New("response is nil") |
| 386 | } |
| 387 | |
| 388 | responseBody := []byte{} |
| 389 | if resp.Body != nil { |
| 390 | responseBody, _ = io.ReadAll(resp.Body) |
| 391 | if len(responseBody) == 0 { |
| 392 | return "", nil |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | result := string(responseBody) |
| 397 | |
| 398 | // 压缩json数据,减少打印的信息 |
| 399 | simpleResult := result |
| 400 | regex := regexp.MustCompile(`:".*?[^\\]"`) |
| 401 | simpleResult = regex.ReplaceAllStringFunc(simpleResult, func(old string) string { |
| 402 | if len(old) > 26 { |
| 403 | return old[:23] + "...\"" |
| 404 | } |
| 405 | return old |
| 406 | }) |
| 407 | |
| 408 | printRespStr := fmt.Sprintf("RESPONSE \n\tcode: %v \n\thead: %v \n\tbody: %s", |
| 409 | resp.StatusCode, resp.Header, simpleResult) |
| 410 | SmartIDELog.Debug(printRespStr) |
| 411 | |
| 412 | return result, nil |
| 413 | } |
| 414 | |
| 415 | func AddUsernamePassword4ActualGitRpoUrl(actualGitRepoUrl string, gitUsername, gitPassword string) (string, error) { |
| 416 | if gitUsername == "" || gitPassword == "" { |