|
|
преди 4 часа | |
|---|---|---|
| .. | ||
| cmd | преди 4 часа | |
| README.md | преди 4 часа | |
| books.handlers.persisttransactions | преди 4 часа | |
| go.mod | преди 4 часа | |
| go.sum | преди 4 часа | |
| main.go | преди 4 часа | |
| transactions.log | преди 4 часа | |
Minimal Go service that accepts POST /persist with a JSON transaction body and persists it.
Usage
cd Books/books.handlers.persisttransactions
go build -v
PERSIST_FILE=transactions.log PORT=:8080 ./books.handlers.persisttransactions
# or run directly
PERSIST_FILE=transactions.log go run .
Example request:
curl -X POST http://localhost:8080/persist -d '{"id":123, "amount": 9.99}' -H 'Content-Type: application/json'
Environment
PERSIST_FILE — optional path to append JSON lines of incoming transactions.PORT — optional listen address (default :8080).