feat: add static file serving and refactor route registration

This commit is contained in:
2025-12-16 22:40:31 +08:00
parent 55c40c4601
commit 2a12e1c3a9
7 changed files with 41 additions and 21 deletions

View File

@@ -3,15 +3,12 @@ package http
import (
"context"
"database/sql"
"sort"
"strings"
"quyun/v2/app/commands"
"quyun/v2/app/errorx"
"quyun/v2/app/http/super"
"quyun/v2/app/jobs"
"quyun/v2/app/services"
"quyun/v2/app/tenancy"
"quyun/v2/database"
_ "quyun/v2/docs"
"quyun/v2/providers/app"
@@ -85,17 +82,8 @@ func Serve(cmd *cobra.Command, args []string) error {
}))
rootGroup := svc.Http.Engine.Group("")
tenantGroup := svc.Http.Engine.Group("/t/:tenant_code", tenancy.Middleware(svc.DB))
sort.SliceStable(svc.Routes, func(i, j int) bool {
return svc.Routes[i].Name() < svc.Routes[j].Name()
})
for _, route := range svc.Routes {
if strings.HasPrefix(route.Name(), "super") {
route.Register(rootGroup)
continue
}
route.Register(tenantGroup)
route.Register(rootGroup)
}
return svc.Http.Serve(ctx)