mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
- Updated the Execute methods in various executors (GeminiCLIExecutor, GeminiExecutor, IFlowExecutor, OpenAICompatExecutor, QwenExecutor) to return a response and error as named return values for improved clarity. - Enhanced error handling by deferring failure tracking in usage reporters, ensuring that failures are reported correctly. - Improved response body handling by ensuring proper closure and error logging for HTTP responses across all executors. - Added failure tracking and reporting in the usage reporter to capture unsuccessful requests. - Updated the usage logging structure to include a 'Failed' field for better tracking of request outcomes. - Adjusted the logic in the RequestStatistics and Record methods to accommodate the new failure tracking mechanism.
21 lines
487 B
Go
21 lines
487 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,
|
|
"failed_requests": snapshot.FailureCount,
|
|
})
|
|
}
|