实现Web静态文件分发

This commit is contained in:
GoEdgeLab
2020-09-26 11:21:52 +08:00
parent 86229e5a6f
commit afe4156395
14 changed files with 216 additions and 33 deletions

View File

@@ -188,7 +188,21 @@ func (this *CreateAction) RunPost(params struct {
// Web地址
switch params.ServerType {
case serverconfigs.ServerTypeHTTPWeb:
webResp, err := this.RPC().HTTPWebRPC().CreateHTTPWeb(this.AdminContext(), &pb.CreateHTTPWebRequest{Root: params.WebRoot})
var rootJSON []byte
var err error
if len(params.WebRoot) > 0 {
rootConfig := &serverconfigs.HTTPRootConfig{}
rootConfig.IsOn = true
rootConfig.Dir = params.WebRoot
rootConfig.Indexes = []string{"index.html", "index.htm"}
rootJSON, err = json.Marshal(rootConfig)
if err != nil {
this.ErrorPage(err)
return
}
}
webResp, err := this.RPC().HTTPWebRPC().CreateHTTPWeb(this.AdminContext(), &pb.CreateHTTPWebRequest{RootJSON: rootJSON})
if err != nil {
this.ErrorPage(err)
return