refactor query.go

This commit is contained in:
yusing 2025-01-10 06:48:17 +08:00
parent e28c4a1b4d
commit c572382f6a

View file

@ -6,14 +6,13 @@ import (
"github.com/yusing/go-proxy/internal/homepage" "github.com/yusing/go-proxy/internal/homepage"
"github.com/yusing/go-proxy/internal/route/entry" "github.com/yusing/go-proxy/internal/route/entry"
provider "github.com/yusing/go-proxy/internal/route/provider/types" provider "github.com/yusing/go-proxy/internal/route/provider/types"
"github.com/yusing/go-proxy/internal/route/types"
route "github.com/yusing/go-proxy/internal/route/types" route "github.com/yusing/go-proxy/internal/route/types"
"github.com/yusing/go-proxy/internal/utils/strutils" "github.com/yusing/go-proxy/internal/utils/strutils"
) )
func HomepageConfig(useDefaultCategories bool) homepage.Config { func HomepageConfig(useDefaultCategories bool) homepage.Config {
hpCfg := homepage.NewHomePageConfig() hpCfg := homepage.NewHomePageConfig()
GetHTTPRoutes().RangeAll(func(alias string, r types.HTTPRoute) { GetHTTPRoutes().RangeAll(func(alias string, r route.HTTPRoute) {
en := r.RawEntry() en := r.RawEntry()
item := en.Homepage item := en.Homepage
if item == nil { if item == nil {
@ -86,11 +85,11 @@ func RoutesByAlias(typeFilter ...route.RouteType) map[string]any {
for _, t := range typeFilter { for _, t := range typeFilter {
switch t { switch t {
case route.RouteTypeReverseProxy: case route.RouteTypeReverseProxy:
GetHTTPRoutes().RangeAll(func(alias string, r types.HTTPRoute) { GetHTTPRoutes().RangeAll(func(alias string, r route.HTTPRoute) {
rts[alias] = r rts[alias] = r
}) })
case route.RouteTypeStream: case route.RouteTypeStream:
GetStreamRoutes().RangeAll(func(alias string, r types.StreamRoute) { GetStreamRoutes().RangeAll(func(alias string, r route.StreamRoute) {
rts[alias] = r rts[alias] = r
}) })
} }