将 web 框架从 gin 切换到 fiber

This commit is contained in:
2025-05-15 10:04:28 +08:00
parent 8b7dc9e4ff
commit b29882f0a7
8 changed files with 46 additions and 24 deletions

View File

@@ -2,13 +2,12 @@ package handlers
import (
"fmt"
"github.com/gofiber/fiber/v2"
"proxy-server/server/debug"
"slices"
"github.com/gin-gonic/gin"
)
func GetConsuming(c *gin.Context) {
func GetConsuming(c *fiber.Ctx) error {
list := debug.ConsumingList()
// sort by total time
slices.SortFunc(list, func(a debug.Consuming, b debug.Consuming) int {
@@ -25,12 +24,12 @@ func GetConsuming(c *gin.Context) {
times := list[i]
strList[i] = fmt.Sprintf("Auth: %s, Data: %s, Proxy: %s, Total: %s", times.Auth, times.Data, times.Proxy, times.Total)
}
c.JSON(200, strList)
return c.JSON(strList)
}
func RestConsuming(c *gin.Context) {
func RestConsuming(c *fiber.Ctx) error {
debug.InitConsumingList()
c.JSON(200, gin.H{
return c.JSON(fiber.Map{
"message": "success",
})
}