Implement web API foundation

Add application container, Gin router, graceful shutdown handler,
and version endpoint. This establishes the skeleton for the WebDisk
HTTP API as described in the architecture.

- Add internal/app/WebApp for runtime dependencies and version
- Add internal/server/router with GET /api/v1/version route
- Add graceful shutdown runner with signal handling in cmd/serve
- Add internal/api/ErrorResponse for standard HTTP error body
- Update roadmap, architecture, and decisions documentation
This commit is contained in:
2026-04-27 23:06:06 +08:00
parent c0c34eb914
commit 7fb125ea87
15 changed files with 469 additions and 32 deletions

View File

@@ -6,6 +6,7 @@
|---------|--------|-------|
| CLI config management | ⬜ plan | |
| JWT authentication | ⬜ plan | access + refresh tokens, refresh token in DB |
| Web API foundation | ✅ skeleton | WebApp composition, Gin router, graceful shutdown, `GET /api/v1/version` |
| File upload/download/manage APIs | ⬜ plan | REST API via Gin |
| Admin endpoints | ⬜ plan | user CRUD for superusers |
| WebDAV | ⬜ plan | future v0 or v1 |
@@ -15,17 +16,18 @@
Package-level implementation order (each task includes unit tests):
1. `internal/config` — Viper loader, config struct
2. `internal/model` — domain types, error codes
3. `internal/api` — JSON response helpers
4. `internal/auth`JWT utils
5. `internal/storage` — backend interface + local fs
6. `internal/repository` interfaces + GORM/SQLite impl
7. `internal/service` — auth, file, admin services
8. `internal/middleware` — requestid, logger, cors, auth
9. `internal/handler` — auth, file, admin handlers
10. `internal/server`Gin wiring, route registration
11. `cmd/serve.go`, `cmd/config.go`, `cmd/status.go`
12. Integration tests
2. `internal/app` — runtime dependency container ✅ skeleton
3. `internal/model` — domain types, error codes
4. `internal/api`error response helpers ✅ skeleton
5. `internal/auth` — JWT utils
6. `internal/storage` — backend interface + local fs
7. `internal/repository` — interfaces + GORM/SQLite impl
8. `internal/service` — auth, file, admin services
9. `internal/middleware` — logger, cors, auth
10. `internal/handler`auth, file, admin handlers ✅ version skeleton
11. `internal/server` — Gin router, route registration, graceful shutdown ✅ skeleton
12. `cmd/serve.go`, `cmd/config.go`, `cmd/status.go` ✅ serve skeleton
13. Integration tests
## Future