Skip to content

Commit

Permalink
refactor: remove pages, combine grpc http port
Browse files Browse the repository at this point in the history
  • Loading branch information
naiba committed Oct 20, 2024
1 parent 4fc0aad commit 606e10c
Show file tree
Hide file tree
Showing 20 changed files with 368 additions and 761 deletions.
41 changes: 20 additions & 21 deletions cmd/dashboard/controller/api_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/gin-gonic/gin"

"github.com/naiba/nezha/model"
"github.com/naiba/nezha/pkg/mygin"
"github.com/naiba/nezha/service/singleton"
)

Expand All @@ -18,30 +17,30 @@ type apiV1 struct {
func (v *apiV1) serve() {
r := v.r.Group("")
// 强制认证的 API
r.Use(mygin.Authorize(mygin.AuthorizeOption{
MemberOnly: true,
AllowAPI: true,
IsPage: false,
Msg: "访问此接口需要认证",
Btn: "点此登录",
Redirect: "/login",
}))
// r.Use(mygin.Authorize(mygin.AuthorizeOption{
// MemberOnly: true,
// AllowAPI: true,
// IsPage: false,
// Msg: "访问此接口需要认证",
// Btn: "点此登录",
// Redirect: "/login",
// }))
r.GET("/server/list", v.serverList)
r.GET("/server/details", v.serverDetails)
// 不强制认证的 API
mr := v.r.Group("monitor")
mr.Use(mygin.Authorize(mygin.AuthorizeOption{
MemberOnly: false,
IsPage: false,
AllowAPI: true,
Msg: "访问此接口需要认证",
Btn: "点此登录",
Redirect: "/login",
}))
mr.Use(mygin.ValidateViewPassword(mygin.ValidateViewPasswordOption{
IsPage: false,
AbortWhenFail: true,
}))
// mr.Use(mygin.Authorize(mygin.AuthorizeOption{
// MemberOnly: false,
// IsPage: false,
// AllowAPI: true,
// Msg: "访问此接口需要认证",
// Btn: "点此登录",
// Redirect: "/login",
// }))
// mr.Use(mygin.ValidateViewPassword(mygin.ValidateViewPasswordOption{
// IsPage: false,
// AbortWhenFail: true,
// }))
mr.GET("/:id", v.monitorHistoriesById)
}

Expand Down
Loading

0 comments on commit 606e10c

Please sign in to comment.