mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
- Introduced in-memory request statistics aggregation in `LoggerPlugin`. - Added new structures for detailed metrics collection (e.g., token breakdown, request success/failure). - Implemented `/usage` management API endpoint for retrieving aggregated statistics. - Updated management handlers to support the new usage statistics functionality. - Enhanced documentation to describe the usage metrics API.
18 lines
427 B
Go
18 lines
427 B
Go
package management
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/usage"
|
|
)
|
|
|
|
// GetUsageStatistics returns the in-memory request statistics snapshot.
|
|
func (h *Handler) GetUsageStatistics(c *gin.Context) {
|
|
var snapshot usage.StatisticsSnapshot
|
|
if h != nil && h.usageStats != nil {
|
|
snapshot = h.usageStats.Snapshot()
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{"usage": snapshot})
|
|
}
|