scala-webapp-template
scala-webapp-template copied to clipboard
Refactor Api layer
The current approach for invoking the backend API is somewhat annoying:
- We have an ApiClient, while that's a trait, we just have a specific implementation, making it a class can simplify this.
- Still, ApiClient implements just every method, which has lots of repetitive code and the class file gets unnecessarily long (seems one of those rare cases where the cake-pattern could be helpful0.
There is also an alternative way, what if each Api class knows how to invoke backend? this way, we could keep Api files to be self-contained.
I think that the alternative approach is worth exploring.