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

Add additional API functionality #39

Merged
merged 2 commits into from May 17, 2022
Merged

Add additional API functionality #39

merged 2 commits into from May 17, 2022

Conversation

samcoe
Copy link
Contributor

@samcoe samcoe commented May 11, 2022

This PR adds additional API functionality that is necessary for gh to utilize go-gh.

  • Added optionsNeedResolution to avoid unnecessary config loading
  • Exported api.HandleHTTPError to allow users access to use our error handling
  • Added RESTClient.Raw function to allow users direct access to an http response
  • Renamed pkg/api/http.go to pkg/api/errors.go to more accurately reflect its contents

Based on top of #30
Corresponding gh PR cli/cli#5614 that uses these changes.
cc cli/cli#5560

@samcoe samcoe self-assigned this May 11, 2022
@samcoe samcoe force-pushed the api-integration branch 5 times, most recently from cabf149 to ba8070c Compare May 13, 2022 08:29
pkg/api/client.go Outdated Show resolved Hide resolved
}

// HandleHTTPError parses a http.Response into a HTTPError.
func HandleHTTPError(resp *http.Response) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not in love with this name, I am open to suggestions on a better one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine! Ideally, no integrators will ever need to call this directly, since all the other higher-level API methods call this internally on non-HTTP 200 statuses. However, I understand we need this from cli/cli?

Copy link
Contributor Author

@samcoe samcoe May 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there are numerous places in cli/cli that call api.HandleHTTPError directly rather than making requests through an api.Client interface.

@samcoe samcoe marked this pull request as ready for review May 13, 2022 08:41
@samcoe samcoe requested a review from mislav May 13, 2022 08:41
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Thank you for the hard work 🙇

pkg/api/client.go Outdated Show resolved Hide resolved
}

// HandleHTTPError parses a http.Response into a HTTPError.
func HandleHTTPError(resp *http.Response) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine! Ideally, no integrators will ever need to call this directly, since all the other higher-level API methods call this internally on non-HTTP 200 statuses. However, I understand we need this from cli/cli?

Base automatically changed from unix-socket to trunk May 17, 2022 19:25
@samcoe samcoe merged commit b7131b0 into trunk May 17, 2022
@samcoe samcoe deleted the api-integration branch May 17, 2022 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants