-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use fiber drop-in replace gin
- Loading branch information
1 parent
07fcfc4
commit 4b032da
Showing
22 changed files
with
213 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package consts | ||
|
||
// ContextKey is a type of context key | ||
type ContextKey string | ||
|
||
const ( | ||
// ContextKeyRequestID is a context key for request id | ||
ContextKeyRequestID ContextKey = "request_id" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package v1 | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/gofiber/fiber/v2" | ||
"github.com/hitokoto-osc/Moe/util/web" | ||
) | ||
|
||
// Ping is a controller func that impl a Pong response, | ||
// intended to notify the client that server is ok | ||
func Ping(c *gin.Context) { | ||
web.Success(c, map[string]interface{}{}) | ||
func Ping(c *fiber.Ctx) error { | ||
return web.Success(c, map[string]interface{}{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
package v1 | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/gofiber/fiber/v2" | ||
"github.com/hitokoto-osc/Moe/cache" | ||
"github.com/hitokoto-osc/Moe/task/status/types" | ||
"github.com/hitokoto-osc/Moe/util/web" | ||
) | ||
|
||
// Statistic 是用于返回统计分析结果的控制器 | ||
func Statistic(c *gin.Context) { | ||
func Statistic(c *fiber.Ctx) error { | ||
data, ok := cache.GetStatusData() | ||
if !ok { | ||
web.Fail(c, map[string]interface{}{}, -1) | ||
return | ||
return web.Fail(c, map[string]interface{}{}, -1) | ||
} | ||
if data.DownServer == nil { | ||
data.DownServer = make([]types.DownServerData, 0) | ||
} | ||
web.Success(c, data) | ||
return web.Success(c, data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.