实现路径规则部分功能

This commit is contained in:
刘祥超
2020-09-21 19:51:50 +08:00
parent 47bf305df6
commit a4b806fa7e
50 changed files with 630 additions and 114 deletions

View File

@@ -0,0 +1,38 @@
package location
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
)
// 路径规则详情
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.TinyMenu("basic")
}
func (this *IndexAction) RunGet(params struct {
LocationId int64
}) {
locationConfigResp, err := this.RPC().HTTPLocationRPC().FindEnabledHTTPLocationConfig(this.AdminContext(), &pb.FindEnabledHTTPLocationConfigRequest{LocationId: params.LocationId})
if err != nil {
this.ErrorPage(err)
return
}
locationConfig := &serverconfigs.HTTPLocationConfig{}
err = json.Unmarshal(locationConfigResp.LocationJSON, locationConfig)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["locationId"] = locationConfig.Id
this.Data["locationConfig"] = locationConfig
this.Show()
}

View File

@@ -0,0 +1,20 @@
package location
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(locationutils.NewLocationHelper()).
Helper(serverutils.NewServerHelper()).
Prefix("/servers/server/settings/locations/location").
GetPost("", new(IndexAction)).
EndAll()
})
}