Files
proxy/server/web/handlers/debug.go

36 lines
758 B
Go

package handlers
import (
"fmt"
"github.com/gofiber/fiber/v2"
"proxy-server/server/debug"
"slices"
)
func GetConsuming(c *fiber.Ctx) error {
list := debug.ConsumingList()
// sort by total time
slices.SortFunc(list, func(a debug.Consuming, b debug.Consuming) int {
if a.Total < b.Total {
return 1
} else if a.Total > b.Total {
return -1
}
return 0
})
// map to string
strList := make([]string, len(list))
for i := 0; i < len(list); i++ {
times := list[i]
strList[i] = fmt.Sprintf("Auth: %s, Data: %s, Proxy: %s, Total: %s", times.Auth, times.Data, times.Proxy, times.Total)
}
return c.JSON(strList)
}
func RestConsuming(c *fiber.Ctx) error {
debug.InitConsumingList()
return c.JSON(fiber.Map{
"message": "success",
})
}