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: add optional future outputs for requests #187

Merged
merged 1 commit into from
Jun 5, 2020
Merged

http: add optional future outputs for requests #187

merged 1 commit into from
Jun 5, 2020

Conversation

zeylahellyer
Copy link
Member

When the user uses a retrieval request, like getting a user by ID, the future output is a Result<Option<T>>. The code to handle 404 response status codes didn't actually exist, so it'd always either be Ok(Some(T)) or Err(E).

This patch adds support for handling 404 responses and returning Ok(None) where encountered on select retrieval routes.

Here's an example of output:

Getting guild member for user 1
Ok(None)
Getting guild member for user 640434332485287936
Ok(Some(Member { deaf: false, guild_id: None, hoisted_role: Non.....

Closes #157.

When the user uses a retrieval request, like getting a user by ID, the
future output is a `Result<Option<T>>`. The code to handle 404 response
status codes didn't actually exist, so it'd always either be
`Ok(Some(T))` or `Err(E)`.

This patch adds support for handling 404 responses and returning
`Ok(None)` where encountered on select retrieval routes.

Here's an example of output:

```
Getting guild member for user 1
Ok(None)
Getting guild member for user 640434332485287936
Ok(Some(Member { deaf: false, guild_id: None, hoisted_role: Non.....
```

Closes #157.

Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
@zeylahellyer zeylahellyer added the c-http Affects the http crate label Jun 4, 2020
@zeylahellyer zeylahellyer requested a review from AEnterprise June 4, 2020 01:44
Copy link
Member

@AEnterprise AEnterprise left a comment

Choose a reason for hiding this comment

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

Looks good and works fine. huge simplification on the bot side to work with

@Erk- Erk- merged commit 48a4ae8 into twilight-rs:master Jun 5, 2020
@zeylahellyer zeylahellyer deleted the http-request-optional-future-outputs branch June 9, 2020 17:06
@7596ff 7596ff added the t-fix Fixes a bug in the library label Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-http Affects the http crate t-fix Fixes a bug in the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http client doesn't return none when the user is not found
4 participants