A CRUD API for managing employee in-memory records
200 OK
[
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"dateOfBirth": "1985-05-15",
"email": "[email protected]",
"isActive": true,
"department": "Engineering",
"role": "Software Developer"
},
{
"id": 2,
"firstName": "Jane",
"lastName": "Smith",
"dateOfBirth": "1990-09-22",
"email": "[email protected]",
"isActive": true,
"department": "Marketing",
"role": "Marketing Specialist"
}
]
Request sample
{
"firstName": "Jane",
"lastName": "Smith",
"dateOfBirth": "1990-09-22",
"email": "[email protected]",
"isActive": true,
"department": "Marketing",
"role": "Marketing Specialist"
}
200 OK
{
"id": 1
}
400 Bad request
{
"fields": ["email", "dateOfBirth"]
}
200 OK
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"dateOfBirth": "1985-05-15",
"email": "[email protected]",
"isActive": true,
"department": "Engineering",
"role": "Software Developer"
}
404 Not found
{
"id": 1
}
200 OK
{
"message": "update success",
"data": {
"firstName": "Bruce",
"lastName": "Wayne",
"role": "CEO"
}
}
200 OK
{
"message": "delete success",
"data": {
"id": 1
}
}
cd path/to/ecrud
go build -o server cmd/server.go
./server
- Access via
localhost:3000
, ie.GET localhost:3000/employees/1
Start
cd path/to/ecrud
docker build -t arhyth:ecrud .
docker run -p 80:3000 -d --name ecrud arhyth:ecrud
- Access via
localhost
, ie.GET localhost/employees/1
Cleanup
docker stop ecrud
docker rm ecrud
docker rmi arhyth:ecrud