-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
google-api-go-generator: handle google.api.HttpBody for healthcare API
This takes a different approach than the changes made for the ML API (see #241). Healthcare and ML API, strangely, have different formats for HttpBody. They are the only two APIs currently using HttpBody. This change makes any HttpBody call accept an io.Reader, which is used as the HTTP request's Body. Headers can be added using the existing Header() function on the Call. Additional headers and parameters are not added, nor is any processing done on the response. This is quite a bit better than requiring users construct their own *http.Request, because they get type safety on the correct method and URL path parameters via the discovery service. Updates #344. Code looks like this to use: call := fhirService.CreateResource(parent, resourceType, bytes.NewReader(jsonPayload)) call.Header().Set("Content-Type", "application/fhir+json;charset=utf-8") resp, err := call.Do() if err != nil { return fmt.Errorf("CreateResource: %v", err) } defer resp.Body.Close() if resp.StatusCode > 299 { return fmt.Errorf("CreateResource: status %d %s", resp.StatusCode, resp.Status) } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { return fmt.Errorf("Could not read response: %v", err) } Change-Id: I87cbf7535fbdeacf8cf74ba4ead82ecbd9f187f8 Reviewed-on: https://code-review.googlesource.com/c/google-api-go-client/+/39310 Reviewed-by: kokoro <[email protected]> Reviewed-by: Tyler Bui-Palsulich <[email protected]> Reviewed-by: Jean de Klerk <[email protected]>
- Loading branch information
Showing
4 changed files
with
684 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.