Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.24 KB

File metadata and controls

54 lines (39 loc) · 1.24 KB

Orders sample

The reference Firefly Framework Go service. Demonstrates:

  • The five-package layout (interfaces, models, core, web, sdk)
  • startercore.New(...) one-call composition
  • CQRS dispatch with validation + query caching
  • Idempotency replay on POST /api/v1/orders
  • RFC 7807 application/problem+json error rendering
  • Correlation-id propagation
  • Startup banner

Run

go run ./samples/orders/web

Place an order

curl -X POST http://localhost:8080/api/v1/orders \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: order-1' \
  -d '{"customer":"alice","sku":"SKU-1","quantity":2,"total":19.99}'

Repeat the same request — the server returns Idempotent-Replay: true with the originally captured response.

Read the order back

curl http://localhost:8080/api/v1/orders/<id>

The first hit goes to the handler; subsequent reads within 30 s are served from the CQRS query cache (GetOrderQuery.CacheTTL()).

Test

cd samples/orders && go test ./...

Boots the full stack via BuildHandler() against httptest.NewServer and asserts on the wire shape.

Docker

docker build -t orders-web -f samples/orders/web/Dockerfile .
docker run -p 8080:8080 orders-web