mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-09 12:00:25 +08:00
反向代理源站实现使用域名分组
This commit is contained in:
@@ -3,10 +3,11 @@ package models
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
)
|
||||
|
||||
// 解析地址
|
||||
// DecodeAddr 解析地址
|
||||
func (this *Origin) DecodeAddr() (*serverconfigs.NetworkAddressConfig, error) {
|
||||
if len(this.Addr) == 0 || this.Addr == "null" {
|
||||
return nil, errors.New("addr is empty")
|
||||
@@ -15,3 +16,14 @@ func (this *Origin) DecodeAddr() (*serverconfigs.NetworkAddressConfig, error) {
|
||||
err := json.Unmarshal([]byte(this.Addr), addr)
|
||||
return addr, err
|
||||
}
|
||||
|
||||
func (this *Origin) DecodeDomains() []string {
|
||||
var result = []string{}
|
||||
if len(this.Domains) > 0 {
|
||||
err := json.Unmarshal([]byte(this.Domains), &result)
|
||||
if err != nil {
|
||||
remotelogs.Error("Origin.DecodeDomains", err.Error())
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user