增加字符编码/HTTP Header管理

This commit is contained in:
刘祥超
2020-09-16 20:29:13 +08:00
parent 5b35be650b
commit 00084a8f66
23 changed files with 827 additions and 50 deletions

View File

@@ -1,7 +1,12 @@
package charset
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/configutils"
"github.com/iwind/TeaGo/actions"
)
type IndexAction struct {
@@ -16,7 +21,41 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
// TODO
webConfigResp, err := this.RPC().ServerRPC().FindAndInitServerWebConfig(this.AdminContext(), &pb.FindAndInitServerWebRequest{ServerId: params.ServerId})
if err != nil {
this.ErrorPage(err)
return
}
webConfig := &serverconfigs.HTTPWebConfig{}
err = json.Unmarshal(webConfigResp.Config, webConfig)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["webId"] = webConfig.Id
this.Data["charset"] = webConfig.Charset
this.Data["usualCharsets"] = configutils.UsualCharsets
this.Data["allCharsets"] = configutils.AllCharsets
this.Show()
}
func (this *IndexAction) RunPost(params struct {
WebId int64
Charset string
Must *actions.Must
}) {
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebCharset(this.AdminContext(), &pb.UpdateHTTPWebCharsetRequest{
WebId: params.WebId,
Charset: params.Charset,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}