Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http SendHTTPResponse writes to log instead of logger #366

Open
tock-ibm opened this issue Mar 27, 2022 · 0 comments
Open

http SendHTTPResponse writes to log instead of logger #366

tock-ibm opened this issue Mar 27, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@tock-ibm
Copy link
Contributor

tock-ibm commented Mar 27, 2022

// SendHTTPResponse writes HTTP response back including HTTP code number and encode payload

func SendHTTPResponse(w http.ResponseWriter, code int, payload interface{}) {
	response, _ := json.Marshal(payload)
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(code)
	if _, err := w.Write(response); err != nil {
		log.Printf("Warning: failed to write response [%v] to the response writer\n", w)
	}
}
@tock-ibm tock-ibm added the enhancement New feature or request label Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant