mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-04-26 15:25:17 +08:00
反向代理源站实现使用域名分组
This commit is contained in:
@@ -56,6 +56,8 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
MaxIdleConns int32
|
||||
IdleTimeout int
|
||||
|
||||
DomainsJSON []byte
|
||||
|
||||
Description string
|
||||
IsOn bool
|
||||
|
||||
@@ -121,6 +123,15 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
var domains = []string{}
|
||||
if len(params.DomainsJSON) > 0 {
|
||||
err = json.Unmarshal(params.DomainsJSON, &domains)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
createResp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
|
||||
Name: params.Name,
|
||||
Addr: &pb.NetworkAddress{
|
||||
@@ -136,6 +147,7 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
IdleTimeoutJSON: idleTimeoutJSON,
|
||||
MaxConns: params.MaxConns,
|
||||
MaxIdleConns: params.MaxIdleConns,
|
||||
Domains: domains,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -76,6 +76,10 @@ func (this *UpdatePopupAction) RunGet(params struct {
|
||||
idleTimeout = types.Int(config.IdleTimeout.Count)
|
||||
}
|
||||
|
||||
if len(config.Domains) == 0 {
|
||||
config.Domains = []string{}
|
||||
}
|
||||
|
||||
this.Data["origin"] = maps.Map{
|
||||
"id": config.Id,
|
||||
"protocol": config.Addr.Protocol,
|
||||
@@ -89,6 +93,7 @@ func (this *UpdatePopupAction) RunGet(params struct {
|
||||
"idleTimeout": idleTimeout,
|
||||
"maxConns": config.MaxConns,
|
||||
"maxIdleConns": config.MaxIdleConns,
|
||||
"domains": config.Domains,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
@@ -110,6 +115,8 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
MaxIdleConns int32
|
||||
IdleTimeout int
|
||||
|
||||
DomainsJSON []byte
|
||||
|
||||
Description string
|
||||
IsOn bool
|
||||
|
||||
@@ -175,6 +182,15 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
var domains = []string{}
|
||||
if len(params.DomainsJSON) > 0 {
|
||||
err = json.Unmarshal(params.DomainsJSON, &domains)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
_, err = this.RPC().OriginRPC().UpdateOrigin(this.AdminContext(), &pb.UpdateOriginRequest{
|
||||
OriginId: params.OriginId,
|
||||
Name: params.Name,
|
||||
@@ -191,6 +207,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
IdleTimeoutJSON: idleTimeoutJSON,
|
||||
MaxConns: params.MaxConns,
|
||||
MaxIdleConns: params.MaxIdleConns,
|
||||
Domains: domains,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
Reference in New Issue
Block a user