What is the best practice in actix-web to returning a response
⚓ Rust 📅 2025-10-05 👤 surdeus 👁️ 6I'm migrating from Java to Rust
In the Java world, when I code Spring, I often create a class called RestBean and wrap every response with it to get a json response like this
{
  "code": 200,
  "body": {/*some data*/},
  "message": "ok"
}
I learnt this trick from a very outdated tutorial, I know is not the best practice.
But Rust is not Java, I think there is a more unified way to do that.
Should I keep wrapping the response with something like RestBean or stop doing that?
PS: returning the status code in json could be duplicated with the HTTP status code, which is not the best practice.
1 post - 1 participant
🏷️ Rust_feed