mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-25 02:21:05 +01:00
api: homepage config json not longer include default url
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/yusing/go-proxy/internal/common"
|
||||
"github.com/yusing/go-proxy/internal/homepage"
|
||||
route "github.com/yusing/go-proxy/internal/route"
|
||||
"github.com/yusing/go-proxy/internal/route/entry"
|
||||
@@ -33,17 +31,6 @@ func DumpProviders() map[string]*proxy.Provider {
|
||||
}
|
||||
|
||||
func HomepageConfig() homepage.Config {
|
||||
var proto, port string
|
||||
domains := instance.value.MatchDomains
|
||||
cert, _ := instance.autocertProvider.GetCert(nil)
|
||||
if cert != nil {
|
||||
proto = "https"
|
||||
port = common.ProxyHTTPSPort
|
||||
} else {
|
||||
proto = "http"
|
||||
port = common.ProxyHTTPPort
|
||||
}
|
||||
|
||||
hpCfg := homepage.NewHomePageConfig()
|
||||
routes.GetHTTPRoutes().RangeAll(func(alias string, r types.HTTPRoute) {
|
||||
en := r.RawEntry()
|
||||
@@ -61,6 +48,8 @@ func HomepageConfig() homepage.Config {
|
||||
return
|
||||
}
|
||||
|
||||
item.Alias = alias
|
||||
|
||||
if item.Name == "" {
|
||||
item.Name = strutils.Title(
|
||||
strings.ReplaceAll(
|
||||
@@ -102,13 +91,7 @@ func HomepageConfig() homepage.Config {
|
||||
item.SourceType = string(proxy.ProviderTypeFile)
|
||||
}
|
||||
|
||||
if item.URL == "" {
|
||||
if len(domains) > 0 {
|
||||
item.URL = fmt.Sprintf("%s://%s%s:%s", proto, strings.ToLower(alias), domains[0], port)
|
||||
}
|
||||
}
|
||||
item.AltURL = r.TargetURL().String()
|
||||
|
||||
hpCfg.Add(item)
|
||||
})
|
||||
return hpCfg
|
||||
|
||||
Reference in New Issue
Block a user