blitz
blitz copied to clipboard
Add `ureq` backend for `blitz-net`
Addresses #181
TODO
(These are just copied from the above issue :P)
- [x] Be part of the existing blitz-net crate with feature flags for each backend
- [x] Use the new 3.x version of ureq
- [x] Split the reqwest and ureq implementations in separate files/modules
- [x] Use a threadpool to allow for multiple concurrent requests
- [x] Implement the blitz_net::get_text method as well as blitz_net::Provider
To test this, set ureq as the default feature in blitz-net, then change packages/blitz/src/lib.rs@L36 like so:
- let html = rt.block_on(blitz_net::get_text(&url));
+ let html = blitz_net::get_text(&url));
@nicoburns I know you'll be gone, but once you're back, I have a couple architecture questions:
- Is there a better way to handle the two
Providers? Right now they are almost the same, except for the fact thatfetch_innerisasyncon thereqwestbackend. I'd like to ofc prevent repeated code but my little brain can't conceptualize how that might look - How should the other packages be modified to not use
tokio(in the case someone is gonna use theureqbackend to avoid an async runtime, for example)? From what I can tell, three packages use it,blitz,blitz-shell, anddioxus-native. Or is that out of scope for this PR (I would be very okay with this :P)?
"Allow edits by maintainers" should be on if you feel inspired haha