Lagom seems to be interesting but I’m having hard time to make something simple. It seems that I haven’t understood how it works and the hello world example, although it works, I don’t understand how to use it.
I’m trying to create a simple restful service that takes at its header two parameters and produces a json object. For instance in the MyService.java I have:
it is not required to manually create json. You can specify Pojo as return object and default JSON serializator will create JSON automatically. Check this
Thanks for your reply. For the headers is there any easier way? It seems that it’s quite complicated the way it’s being done. I have found this but I couldn’t find a working example. What I would like to do is take a token from the header, verify that the token is valid, if not send a json with error, if yes then send a json object with data.
You can also supply validation function instead of headerName.
I use similar approach for JWT validation. If JWT is not valid I throw com.lightbend.lagom.javadsl.api.transport.Forbidden.