mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-10 01:10:29 +08:00
增加字符编码/HTTP Header管理
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package headers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type UpdateSetPopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpdateSetPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *UpdateSetPopupAction) RunGet(params struct {
|
||||
HeaderPolicyId int64
|
||||
HeaderId int64
|
||||
}) {
|
||||
this.Data["headerPolicyId"] = params.HeaderPolicyId
|
||||
this.Data["headerId"] = params.HeaderId
|
||||
|
||||
headerResp, err := this.RPC().HTTPHeaderRPC().FindEnabledHTTPHeaderConfig(this.AdminContext(), &pb.FindEnabledHTTPHeaderConfigRequest{HeaderId: params.HeaderId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
headerConfig := &shared.HTTPHeaderConfig{}
|
||||
err = json.Unmarshal(headerResp.Config, headerConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["headerConfig"] = headerConfig
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *UpdateSetPopupAction) RunPost(params struct {
|
||||
HeaderId int64
|
||||
Name string
|
||||
Value string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
Require("请输入Header名称")
|
||||
|
||||
_, err := this.RPC().HTTPHeaderRPC().UpdateHTTPHeader(this.AdminContext(), &pb.UpdateHTTPHeaderRequest{
|
||||
HeaderId: params.HeaderId,
|
||||
Name: params.Name,
|
||||
Value: params.Value,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user