服务支持fastcgi;路径规则支持匹配后缀

This commit is contained in:
GoEdgeLab
2021-05-10 21:13:09 +08:00
parent b78a3a2969
commit 3076a46a7a
26 changed files with 803 additions and 25 deletions

View File

@@ -0,0 +1,70 @@
package fastcgi
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "setting", "index")
this.SecondMenu("fastcgi")
}
func (this *IndexAction) RunGet(params struct {
ServerId int64
}) {
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), params.ServerId)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["webId"] = webConfig.Id
this.Data["fastcgiRef"] = webConfig.FastcgiRef
this.Data["fastcgiConfigs"] = webConfig.FastcgiList
this.Show()
}
func (this *IndexAction) RunPost(params struct {
WebId int64
FastcgiRefJSON []byte
FastcgiJSON []byte
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的Fastcgi设置", params.WebId)
// TODO 检查配置
fastcgiRef := &serverconfigs.HTTPFastcgiRef{}
err := json.Unmarshal(params.FastcgiRefJSON, fastcgiRef)
if err != nil {
this.ErrorPage(err)
return
}
fastcgiRefJSON, err := json.Marshal(fastcgiRef)
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebFastcgi(this.AdminContext(), &pb.UpdateHTTPWebFastcgiRequest{
WebId: params.WebId,
FastcgiJSON: fastcgiRefJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}