fix(api): align upload permissions and mount robots and swagger routes

This commit is contained in:
ryan
2026-08-30 17:53:42 +08:00
parent 7c5c196ede
commit 374289bfda
10 changed files with 6718 additions and 110 deletions
@@ -7,6 +7,7 @@ package driver_http
import (
"Wavelet/core"
"Wavelet/core/contracts"
_ "Wavelet/docs" // swagger documentation registration
"Wavelet/pkg/util"
"context"
"errors"
@@ -17,6 +18,8 @@ import (
"time"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
)
const (
@@ -207,6 +210,19 @@ func (p *Plugin) Start(ctx context.Context) error {
}
}
// Mount Swagger in non-production environments
if p.coreCtx != nil {
var appCfg httpAppConfig
_ = p.coreCtx.Config().Bind("app", &appCfg)
if appCfg.Env != "production" && appCfg.Env != "prod" {
swaggerHandler := ginSwagger.WrapHandler(swaggerFiles.Handler)
p.engine.GET("/swagger/*any", swaggerHandler)
if appCfg.APIPrefix != "" {
p.engine.GET(appCfg.APIPrefix+"/swagger/*any", swaggerHandler)
}
}
}
registerFrontend(p.engine, frontendAssets())
p.server = &http.Server{