I like reqwest .
I just do not always like seeing raw reqwest patterns repeated all over my application code.
That is the whole reason src/utils/web.rs exists.
I don't need full HTTP framework. I just need one place to keep a few recurring things:
response decoding
basic header preparation
a default User-Agent
a simpler response type for the rest of the app
A smaller response model
The file starts here:
#[derive(Debug, Clone, Serialize, Deserialize)] pub enum ResponseBody { Json ( Value ), Text ( String ), Binary ( Bytes ), }
#[derive(Debug, Clone)] pub struct HttpReply { pub status : StatusCode , pub headers : HeaderMap , pub body : ResponseBody , }
Enter fullscreen mode
Exit fullscreen mode
That already helps me.
Instead of passing raw reqwest::Response deeper into the app, I get a smaller local type that matches how this project actually thinks about HTTP replies.
That is enough abstraction for me.…