Notifier is an example of a simple notification microservice. It is written in the Golang language. It uses RabbitMQ for message broker and MongoDB to store data.
- Build
go.sumfiles
# build for consumer
$ cd ./consumer
$ go mod tidy
# build for sender
$ cd ./sender
$ go mod tidy- Start app
# to start standard dev mode
$ make start-dev
# to start standard production mode
$ make start-prod
# to start the dev daemon
$ make start-dev-d
# to start the production daemon
$ make start-prod-d- Install
HTTPiecommand-line HTTP client
# brew
$ brew install httpie
# apt
$ apt install httpie
# pip
$ pip3 install httpie- Start bash tests
# change access rights for `tests.sh`
$ chmode 777 ./tests.sh
# start tests
$ sh ./tests.shRequest format
{} // dictionary, array or other query parametersResponse format
// Success:
{
"status": "success", // status success
"data": {} // dictionary, array or other request results
}// Error:
{
"status": "error", // status error
"error": {
"code": 2000, // custom error code
"message": "" // short error description
}
}| Custom code | HTTP code | Description |
|---|---|---|
| 404 | 404 | Route not found |
| 505 | 505 | Method not allowed |
| 500 | 500 | Internal server error |
| 2000 | 400 | Validation error |
| 2010 | 400 | Object not found |
Method: POST
/api/notifications/
Request body scheme:
{
"to": [], // e-mails for mailing
"subject": "", // mail subject
"body": "" // mail body
}Response body scheme:
{
"status": "success", // operation status
"data": {
"id": "", // notification id
"created_at": "", // date of create
"updated_at": "", // date of update
"to": [], // e-mails for mailing
"subject": "", // mail subject
"body": "", // mail body
"completed": true // completed status
}
}Method: GET
/api/notifications/:id
Response body scheme:
{
"status": "success", // operation status
"data": {
"id": "", // notification id
"created_at": "", // date of create
"updated_at": "", // date of update
"to": [], // e-mails for mailing
"subject": "", // mail subject
"body": "", // mail body
"completed": true // completed status
}
}Method: GET
/api/notifications/?limit=<int>&offset=<int>&to=<[]str>
Response body scheme:
{
"status": "success", // operation status
"data": [
{
"id": "", // notification id
"created_at": "", // date of create
"updated_at": "", // date of update
"to": [], // e-mails for mailing
"subject": "", // mail subject
"body": "", // mail body
"completed": true // completed status
}
]
}