mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-07 08:06:37 +08:00
fix(api): align upload permissions and mount robots and swagger routes
This commit is contained in:
@@ -170,6 +170,10 @@ func (p *Plugin) Apply(ctx *core.Context) error {
|
||||
adminRouter := ctx.Router().Group("/api/v1/admin", loginMW, adminMW)
|
||||
handler.RegisterRoutes(adminRouter)
|
||||
|
||||
// Register robots.txt public route
|
||||
ctx.Router().GET("/robots.txt", handler.GetRobotsTXT)
|
||||
ctx.Router().RegisterWhitelist("/robots.txt")
|
||||
|
||||
// 2. Register Background Tasks
|
||||
logSwitchHandler := &service.LogDBSwitchHandler{}
|
||||
ctx.Task().Register(service.LogDBSwitchTask, func(c context.Context, payload []byte) error {
|
||||
|
||||
@@ -23,6 +23,14 @@ func TestAdminPluginUnit(t *testing.T) {
|
||||
// Verify routes
|
||||
routes := ctx.Router().Routes()
|
||||
assert.NotEmpty(t, routes)
|
||||
var hasRobots bool
|
||||
for _, r := range routes {
|
||||
if r.Path == "/robots.txt" && r.Method == "GET" {
|
||||
hasRobots = true
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.True(t, hasRobots, "admin plugin must register /robots.txt")
|
||||
|
||||
// Verify tasks
|
||||
_, ok := ctx.Tasks().Get("admin:system_cleanup")
|
||||
|
||||
Reference in New Issue
Block a user