优化
This commit is contained in:
@@ -5,25 +5,24 @@ import (
|
||||
"strings"
|
||||
|
||||
"kra/internal/biz"
|
||||
"kra/internal/conf"
|
||||
"kra/internal/service/dto"
|
||||
)
|
||||
|
||||
type APIService struct {
|
||||
uc *biz.APIUsecase
|
||||
runtime *conf.Runtime
|
||||
uc *biz.APIUsecase
|
||||
settings biz.RuntimeSettings
|
||||
}
|
||||
|
||||
func NewAPIService(uc *biz.APIUsecase, runtime *conf.Runtime) *APIService {
|
||||
return &APIService{uc: uc, runtime: runtime}
|
||||
func NewAPIService(uc *biz.APIUsecase, settings biz.RuntimeSettings) *APIService {
|
||||
return &APIService{uc: uc, settings: settings}
|
||||
}
|
||||
|
||||
func (s *APIService) NormalizeRoutePath(path string) string {
|
||||
config := s.runtime.Admin()
|
||||
if config == nil || config.RouterPrefix == "" {
|
||||
routerPrefix := s.settings.RouterPrefix()
|
||||
if routerPrefix == "" {
|
||||
return path
|
||||
}
|
||||
prefix := strings.TrimSuffix(config.RouterPrefix, "/")
|
||||
prefix := strings.TrimSuffix(routerPrefix, "/")
|
||||
normalized := strings.TrimPrefix(path, prefix)
|
||||
if normalized == "" {
|
||||
return "/"
|
||||
|
||||
Reference in New Issue
Block a user