Open imjuanleonard opened 5 years ago
Usecase: After using the HTTP client to Do the request. We want to directly unmarshal the response body into a certain struct. If it fails, we just want to know the status code of the API and returns accordingly.
The snippet of working code will be like:
responseBody := YourProgramResponseBodyStruct{} httpStatusCode, err := heimdall.ResponseBody(req, &responseBody)
What good it will do: It reduces the need to write again and again for decoding the response body. Saving lines of code with this abstraction
Usecase: After using the HTTP client to Do the request. We want to directly unmarshal the response body into a certain struct. If it fails, we just want to know the status code of the API and returns accordingly.
The snippet of working code will be like:
What good it will do: It reduces the need to write again and again for decoding the response body. Saving lines of code with this abstraction