多处增加是否独立配置选项

This commit is contained in:
GoEdgeLab
2020-09-23 18:43:38 +08:00
parent 41bddd79c9
commit 72865127b7
50 changed files with 615 additions and 267 deletions

View File

@@ -53,15 +53,25 @@ func (this *IndexAction) RunGet(params struct {
this.Data["gzipConfig"] = gzipConfig
if webConfig.GzipRef == nil {
webConfig.GzipRef = &serverconfigs.HTTPGzipRef{
IsPrior: false,
IsOn: false,
GzipId: 0,
}
}
this.Data["gzipRef"] = webConfig.GzipRef
this.Show()
}
func (this *IndexAction) RunPost(params struct {
WebId int64
GzipId int64
Level int
MinLength string
MaxLength string
WebId int64
GzipRefJSON []byte
GzipId int64
Level int
MinLength string
MaxLength string
Must *actions.Must
}) {
@@ -87,6 +97,14 @@ func (this *IndexAction) RunPost(params struct {
}
}
gzipRef := &serverconfigs.HTTPGzipRef{}
err := json.Unmarshal(params.GzipRefJSON, gzipRef)
if err != nil {
this.ErrorPage(err)
return
}
gzipRef.GzipId = params.GzipId
if params.GzipId > 0 {
_, err := this.RPC().HTTPGzipRPC().UpdateHTTPGzip(this.AdminContext(), &pb.UpdateHTTPGzipRequest{
GzipId: params.GzipId,
@@ -109,24 +127,21 @@ func (this *IndexAction) RunPost(params struct {
return
}
gzipId := resp.GzipId
gzipRef.GzipId = gzipId
}
gzipRef := &serverconfigs.HTTPGzipRef{
IsOn: true,
GzipId: gzipId,
}
gzipRefJSON, err := json.Marshal(gzipRef)
if err != nil {
this.ErrorPage(err)
return
}
gzipRefJSON, err := json.Marshal(gzipRef)
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebGzip(this.AdminContext(), &pb.UpdateHTTPWebGzipRequest{
WebId: params.WebId,
GzipJSON: gzipRefJSON,
})
if err != nil {
this.ErrorPage(err)
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebGzip(this.AdminContext(), &pb.UpdateHTTPWebGzipRequest{
WebId: params.WebId,
GzipJSON: gzipRefJSON,
})
if err != nil {
this.ErrorPage(err)
}
this.Success()