Skip to content

http: add optional future outputs for requests#187

Merged
Erk- merged 1 commit intotwilight-rs:masterfrom
spring4175:http-request-optional-future-outputs
Jun 5, 2020
Merged

http: add optional future outputs for requests#187
Erk- merged 1 commit intotwilight-rs:masterfrom
spring4175:http-request-optional-future-outputs

Conversation

@spring4175
Copy link
Contributor

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>
@spring4175 spring4175 added the c-http Affects the http crate label Jun 4, 2020
@spring4175 spring4175 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
@spring4175 spring4175 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