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

An easy way to avoid throwing on non-200 statuses #52

Closed
artempyanykh opened this issue Nov 5, 2018 · 6 comments
Closed

An easy way to avoid throwing on non-200 statuses #52

artempyanykh opened this issue Nov 5, 2018 · 6 comments
Labels

Comments

@artempyanykh
Copy link

With vanilla Network.HTTP.Client one can just setRequestIgnoreStatus. It looks like that with req I'd need to define MonadHttp with handleHttpException, but this looks like too much hassle if I just want to run requests in IO and handle all responses irregardless of their status codes.

Am I missing something in the config?

@mrkkrp mrkkrp added the question label Nov 5, 2018
@mrkkrp
Copy link
Owner

mrkkrp commented Nov 5, 2018

If you don’t want to define an instance of MonadHttp you can always use runReq and pass HttpConfig there directly. In the config you’ll need to set httpConfigCheckResponse to something like \_ _ _ -> Nothing.

@mrkkrp
Copy link
Owner

mrkkrp commented Nov 6, 2018

Does this answer your question? Can we close this one?

@artempyanykh
Copy link
Author

Ah, I see. Thank you very much for helping @mrkkrp, good to close!

@mrkkrp mrkkrp closed this as completed Nov 6, 2018
@mrkkrp
Copy link
Owner

mrkkrp commented Nov 6, 2018

This is also shown in the docs and readme 😉

@mrkkrp mrkkrp reopened this Nov 6, 2018
@mrkkrp mrkkrp closed this as completed Nov 6, 2018
@artempyanykh
Copy link
Author

@mrkkrp right, just checked Haddock and found mentions of httpConfigCheckResponse. However, in README I couldn't find anything except

Just define handleHttpException accordingly when making your monad instance of MonadHttp and it will play together seamlessly.

Maybe it's worth adding a small note or example? TBH, I was pretty surprised to receive an exception on non-200 response, not exactly the default of a least surprise.

Anyway, sorry for the silly question. I'm new to Haskell and its ecosystem and failed to figure out from the first try how http-client and req play together ¯\_(ツ)_/¯

@mrkkrp
Copy link
Owner

mrkkrp commented Nov 6, 2018

Ah, sorry I just was thinking about runReq itself vs defining a new instance. Never mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants