Example implementation of a profile microservice using Lagom
Make sure you have a running Java environment and sbt set up.
Clone/download the repository and run sbt runAll
inside the project root to start the microservice on port 9000
. It will take a while to set up all dependencies on first run.
DISCLAIMER: This project is for educational purpose only.
The API is defined in ProfileService and implemented in ProfileServiceImpl.
Lagom uses CQRS and Event Sourcing to store and execute requests. The entities behavior is defined in ProfileEntity, Commands, Queries (= Read-only commands) and Events in ProfileCommand and ProfileEvent and the state is stored in ProfileState.
The Profile message is located inside an additional subproject to allow usage outside this project. In real cloud platforms this should be a shared dependency to maintain message integrity across all microservices.
This should only demonstrate the use of Lagom's REST interface.
Action | Method | Description | Parameters | Request body | Response body | Code |
---|---|---|---|---|---|---|
Create profile | PUT | Creates a new profile with <email> and <name> and returns it. |
None | ProfileCreate | Profile | cURL |
Get profile | GET | Returns the profile | UUID | None | Profile | cURL |
Update profile | POST | Updates the profile (id and email are currently immutable) | UUID | Profile | Done | cURL |
Delete profile | DELETE | Deletes the profile | UUID | None | Done | cURL |
Ping | GET | Use for health checks | None | None | Done | cURL |
curl -X PUT -d '{"name":"<name>","email":"<email>"}' localhost:9000/v1/profile
curl localhost:9000/v1/profile/<uuid>
curl -X POST -d '{"id":"<uuid>","email":"<email>","name":"<name>"}' localhost:9000/v1/profile/<uuid>
curl -X DELETE localhost:9000/v1/profile/<uuid>
curl localhost:9000/ping
The project is licensed under the MIT License.