I've always liked the idea of explaining code through writing. I recently published a post on Medium about how to make a GET request in Rust, and I'd love to hear your feedback. Here's the link: https://medium.com/p/a21377f301a4
Here's some feedback:
- You don't need to wrap the url inside the
formatmacro to append stuff, since you are receiving an ownedStringafter all. - It would be better if you did not mutate the url from the callee, and instead leave that responsibility to the caller.
- You're rebuilding the client on every request. This is considered a bad practice; you should reuse the client instead as this allows you to reuse any connections already established with the target.
- It's misleading that you start by saying that you can use reqwest to make asynchronous requests, and then proceed to use it to make a blocking, synchronous request in the provided example. You should at least clarify how you're using it.
Thank you very much; I’ll work through the example and follow your advice.
All the advice you gave me is really helping me to improve