-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestAPI - Checklist.txt
More file actions
100 lines (83 loc) · 1.33 KB
/
RestAPI - Checklist.txt
File metadata and controls
100 lines (83 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
`
Step-by-Step Plan to Build a REST API in Go
1. Define the API Contract
- Identify resources (users, orders, products) (DONE)
- Define endpoints
- Define request/response format (JSON)
- Define HTTP methods
- Define status codes
- Optionally create OpenAPI/Swagger specification
5. Implement Routing
GET /expenses
GET /expenses/{id}
POST /expenses
PUT /expenses/{id}
DELETE /expenses/{id}
8. Business Logic Layer
Handler → Service → Repository
10. Middleware
Examples:
- logging
- request ID
- rate limiting
- CORS
11. Error Handling
Example response:
{
"error": "user_not_found",
"message": "User does not exist"
}
13. Logging
Libraries:
- Zap
- Logrus
- Go standard log
14. Configuration
Use environment variables or config libraries.
15. Testing
Unit Tests:
go test ./...
Integration tests for endpoints.
16. API Documentation
Tools:
- Swagger
- Swaggo
17. Database Migrations
Tools:
- golang-migrate
- goose
18. Containerization
Use Docker with a Dockerfile.
19. Deployment
Cloud platforms:
- AWS
- Google Cloud
- DigitalOcean
- Render
20. Monitoring
Tools:
- Prometheus
- Grafana
Typical request flow:
Client
↓
Router
↓
Middleware
↓
Handler
↓
Service
↓
Repository
↓
Database
Minimum API Requirements:
1. HTTP server
2. Router
3. Handlers
4. Models
5. Business logic
6. Database access
7. JSON responses
`