Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix index redirect #418

Merged
merged 2 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions api/apiv1/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
Prefix = ""
)

func Static(e *echo.Echo, prefix string) {
func Static(e *echo.Echo, prefix string, sessionMW echo.MiddlewareFunc) {
Prefix = prefix
var err error
statikFS, err = assets.Assets()
Expand All @@ -35,11 +35,14 @@ func Static(e *echo.Echo, prefix string) {
if err != nil {
return err
}
if c.Request().URL.Path == "" || c.Request().URL.Path == "/" {
c.Request().URL.Path = "/index.html"
}
hanlde := FileServer(Dir("./"))
hanlde.ServeHTTP(c.Response(), c.Request())
return nil
}
e.GET("/", h, middleware.LoginAuth("/user/login", middleware.RedirectTypeHttp).Func())
e.GET("/", h, sessionMW, middleware.LoginAuth("/user/login", middleware.RedirectTypeHttp).Func())
e.GET(prefix, h)
e.GET(prefix+"/*", h)
}
4 changes: 2 additions & 2 deletions app/adminengine/router_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func apiAdmin(server *xecho.Server) {
})
}
//构建前端资源
static.Static(server.Echo, "/ant")
static.Static(server.Echo, "/ant", sessionMW)
//默认目录
echo.NotFoundHandler = func(c echo.Context) error {
if strings.HasPrefix(c.Request().URL.Path, "/api/") {
Expand Down Expand Up @@ -112,7 +112,7 @@ func apiAdmin(server *xecho.Server) {
}

//common proxy
proxy := server.Group("/proxy")
proxy := server.Group("/proxy", sessionMW, loginAuthRedirect)
{
AllMethods := []string{http.MethodGet, http.MethodPost, http.MethodPatch, http.MethodDelete,
http.MethodHead, http.MethodTrace, http.MethodPut, http.MethodConnect, http.MethodOptions}
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/service/resource/app_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ func (r *resource) AppNodeTransferPut(tx *gorm.DB, add, del map[string]interface
RegionName: node.RegionName,
ZoneCode: node.ZoneCode,
ZoneName: node.ZoneName,
CreateTime: time.Now().Unix(),
UpdateTime: time.Now().Unix(),
CreateTime: float64(time.Now().Unix()),
UpdateTime: float64(time.Now().Unix()),
}
itemjson, _ := json.Marshal(item)
xlog.Info("AppNode item: ", zap.String("item", string(itemjson)))
Expand Down
26 changes: 13 additions & 13 deletions pkg/model/db/app_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ type AppNodeAgentView struct {

// AppNode ..
type AppNode struct {
ID int `json:"id" gorm:"not null;column:id"` // id类型?
AppName string `json:"app_name" gorm:"not null;column:app_name"`
Aid int `json:"aid" gorm:"not null;column:aid"` // id类型?
HostName string `json:"host_name" gorm:"not null;column:host_name"`
IP string `json:"ip" gorm:"not null;column:ip;index"`
DeviceID int `json:"device_id" gorm:"not null;column:device_id"`
Env string `json:"env" gorm:"not null"`
RegionCode string `json:"region_code" gorm:"not null"`
RegionName string `json:"region_name" gorm:"not null"`
ZoneCode string `json:"zone_code" gorm:"not null"`
ZoneName string `json:"zone_name" gorm:"not null"`
CreateTime int64 `gorm:"not null;" json:"create_time"`
UpdateTime int64 `gorm:"not null;" json:"update_time"`
ID int `json:"id" gorm:"not null;column:id"` // id类型?
AppName string `json:"app_name" gorm:"not null;column:app_name"`
Aid int `json:"aid" gorm:"not null;column:aid"` // id类型?
HostName string `json:"host_name" gorm:"not null;column:host_name"`
IP string `json:"ip" gorm:"not null;column:ip;index"`
DeviceID int `json:"device_id" gorm:"not null;column:device_id"`
Env string `json:"env" gorm:"not null"`
RegionCode string `json:"region_code" gorm:"not null"`
RegionName string `json:"region_name" gorm:"not null"`
ZoneCode string `json:"zone_code" gorm:"not null"`
ZoneName string `json:"zone_name" gorm:"not null"`
CreateTime float64 `gorm:"not null;" json:"create_time"`
UpdateTime float64 `gorm:"not null;" json:"update_time"`
}

// TableName ..
Expand Down