Skip to content

Commit 07dd77b

Browse files
authored
Merge pull request #40 from smalex-z/backendDocumentation
swagger documentation for the backend hosted at http://localhost:8080/docs/index.html
2 parents ff5fd53 + 66907cd commit 07dd77b

9 files changed

Lines changed: 2472 additions & 15 deletions

File tree

api/controllers/metrics.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ func NewMetricsController(c *collectors.MetricsCollector) *MetricsController {
1919
}
2020

2121
// HandleCurrent returns the most recent metrics snapshot.
22+
// @Summary Get current metrics
23+
// @Description Returns the most recent system metrics snapshot (CPU, Memory, Network, Disk usage)
24+
// @Tags Metrics
25+
// @Produce json
26+
// @Success 200 {object} collectors.MetricsPoint
27+
// @Failure 503 {object} map[string]string "No metrics available yet"
28+
// @Router /metrics/current [get]
2229
func (mc *MetricsController) HandleCurrent(w http.ResponseWriter, r *http.Request) {
2330
latest := mc.Collector.Store.GetLatest()
2431
if latest == nil {
@@ -37,6 +44,13 @@ type historyResponse struct {
3744
}
3845

3946
// HandleHistory returns historical metrics for the requested time range.
47+
// @Summary Get historical metrics
48+
// @Description Returns historical metrics for a specified time range with automatic downsampling for longer periods
49+
// @Tags Metrics
50+
// @Produce json
51+
// @Param range query string false "Time range: minute (default), hour, day, week, or month" default(minute)
52+
// @Success 200 {object} historyResponse
53+
// @Router /metrics/history [get]
4054
func (mc *MetricsController) HandleHistory(w http.ResponseWriter, r *http.Request) {
4155
rangeParam := r.URL.Query().Get("range")
4256

0 commit comments

Comments
 (0)