feat(api): add endpoint to retrieve container stats

- Introduced a new GET endpoint `/docker/stats/:id` to fetch statistics for a specified container by its ID or route alias.
- Implemented the `Stats` function in the `dockerapi` package to handle the request and return container stats in both JSON and WebSocket formats.
- Added error handling for invalid requests and container not found scenarios.
This commit is contained in:
yusing
2026-01-24 00:12:34 +08:00
parent e718cd4c4a
commit cdd60d99cd
4 changed files with 966 additions and 0 deletions

View File

@@ -140,6 +140,7 @@ func NewHandler(requireAuth bool) *gin.Engine {
docker.POST("/start", dockerApi.Start)
docker.POST("/stop", dockerApi.Stop)
docker.POST("/restart", dockerApi.Restart)
docker.GET("/stats/:id", dockerApi.Stats)
}
}