INNER CODE UNIT · Go

PrintPrettyHttpResponse

cyberark/kubeletctl · cmd/print.go:55

func PrintPrettyHttpResponse(resp *http.Response, err error) {
	if err != nil {
		log.Fatal(err)
	}

	bodyBytes, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatal(err)
	}

	bodyString := string(bodyBytes)
	if resp.StatusCode == http.StatusOK {

		// TODO: consider changing it by checking the first and the last byte "{..}".
		// Notice that there is line feed (byte 10 in decimal) that need to consider
		// if isJSON(jsonStringData){
		if isJSON(bodyString) {
			jsonByteData := pretty.Pretty(bodyBytes)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…