|
|
6 小時之前 | |
|---|---|---|
| .. | ||
| cmd | 6 小時之前 | |
| README.md | 6 小時之前 | |
| books.handlers.persisttransactions | 6 小時之前 | |
| go.mod | 6 小時之前 | |
| go.sum | 6 小時之前 | |
| main.go | 6 小時之前 | |
| transactions.log | 6 小時之前 | |
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).