feat: add static file serving and refactor route registration
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user