Project example using Iron and Cats
This is an example project featuring Cats (via Http4s + Circe) and Iron.
This project is a minimal REST API to show the synergy between Iron and Cats.
Test the project
You can run this example using Mill:
millw main.run
Once the server started, you can send a POST request to localhost:8080/register
with an Account-like JSON body:
{
"username": "Iltotore",
"email": "[email protected]",
"password": "Abc123"
}
- username should be alphanumeric
- email should be a valid (existing or not) email
- password should contain at least an upper, a lower and a number
You will receive a JSON response depending on the validity of your values.
If valid
{
"Valid": {
"username": "Iltotore",
"email": "[email protected]",
"password": "Abc123"
}
}
If invalid (bad password and email)
Original request:
{
"username": "Iltotore",
"email": "memyemail.com",
"password": "abc123"
}
Response:
{
"Invalid": [
{
"name": "email",
"message": "Value should be an email"
},
{
"name": "password",
"message": "Value should contain at least an upper, a lower and a number"
}
]
}