Project Setup
Create the directory structure and initialize the Go module
In this walkthrough, you’ll build a complete order management REST API that demonstrates key Humus patterns including service orchestration, cursor-based pagination, and automatic OpenTelemetry instrumentation.
A REST API with two endpoints:
The API integrates with three backend services:
The API orchestrates calls to three backend services with different flows for each endpoint:
sequenceDiagram
participant Client
participant Orders API
participant Data Service
Client->>Orders API: GET /v1/orders?cursor=abc&limit=10
Orders API->>Data Service: Query orders with pagination
Data Service-->>Orders API: Return orders + next cursor
Orders API-->>Client: JSON response with orders arraysequenceDiagram
participant Client
participant Orders API
participant Restriction Service
participant Eligibility Service
participant Data Service
Client->>Orders API: POST /v1/order (order details)
Orders API->>Restriction Service: Check account restrictions
Restriction Service-->>Orders API: Restriction status
Orders API->>Eligibility Service: Validate order eligibility
Eligibility Service-->>Orders API: Eligibility status
Orders API->>Data Service: Save order
Data Service-->>Orders API: Order saved
Orders API-->>Client: Order confirmationBy the end of this walkthrough, you will:
rest.ProduceJson for GET and rest.HandleJson for POSTrest.QueryParam with validationgo version45-60 minutes to complete all sections
The complete source code is available at:
example/rest/orders-walkthrough/
Let’s get started!
Create the directory structure and initialize the Go module
Create a minimal REST API to verify setup
Quickly scaffold endpoints with dummy responses
Implement data storage, restriction, and eligibility service clients
Implement GET /v1/orders with cursor-based pagination
Implement POST /v1/order with service orchestration
Test your API endpoints with Wiremock
Add LGTM stack and OpenTelemetry Collector
Complete end-to-end testing scenarios with full observability