Overview
Mail Service keeps the email side of the Pi out of the other apps. It has no public hostname;
the Mecca API forwards POST /api/notification/subscribe to it and
identifies itself with a clientId header.
Endpoints
GET/
Health check — returns a plain-text greeting.
POST/save/subscriber
Store a subscriber. The caller must send a clientId header, which is saved with the record so each app's subscribers stay separate.
Request
clientId: portfolio
{
"name": "Ada",
"email": "[email protected]"
}
Response
201 Created (empty body)
| Status | When |
|---|---|
400 | clientId header missing |
422 | Body is not {name, email} |
500 | Database write failed |
Project layout
src/
├── main.rs server, routes, CORS
├── controllers/root.rs route handlers
├── services/
│ ├── greeting.rs
│ └── database_service.rs MongoDB access
└── models/subscriber.rs { name, email, client_id }
Running it
cargo build --release
MONGODB_URI=... ./target/release/mail_service