I have a Play! framework (2.3.7) application that has several routes:
/api/set_x
/api/set_y
/api/set_z
/api/launch
Each one of these calls sets a property in an instance of MyObject
. When /api/launch
is called, the instance of MyObject
is validated and if everything is ok it will be persisted and 200 OK will be returned to the user.
How to I keep the state of the instance across multiple calls until /api/launch
is called?
/api/launch
the cache was evicted and a bad request instead of OK will be returned to the user. Is there an elegant way to implement such a thing in Play?
There's no the best solution for your problem and it mostly depends on a specific use case. To keep data between requests you have three possible options:
One of the main feature of Play framework is being stateless on a server side and that should be always in mind while designing an application. So if you are looking for an 'elegant' solution the answer is simple - there's no such. It's all up to a specific case.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.